Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how can i make a program with this kind of output..

Enter a number: 5
0
01
012
0123
01234
012345
01234
0123
012
01
0

Answers were Sorted based on User's Feedback



how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 0..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("enter the limit value :");
scanf("%d",&m);
for(int i=0;i<(2*n+1);i++)
{
printf("\n");
if(i<n)
{
for(int j=0;j<=i;j++)
printf("%d",j);
}
else
{
for(int k=0;k<=j;k++)
printf("%d",k);
j--
}
}
getch();
}

Is This Answer Correct ?    11 Yes 6 No

how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 0..

Answer / vignesh1988i

A SMALL chnge in the above program... in first for loop 'n'
must be changed as 'm'

Is This Answer Correct ?    5 Yes 2 No

how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 0..

Answer / manoj

#include <stdio.h>
int main ()
{
/*declaration*/
int n = 5 ;
int i, j;

/*clean screen*/
clrscr();

/*actual functionality*/
for( i =0; i<=n; i++)
{
printf("\n");
for(j=0; j<=i; j++)
printf("%d",j);
}

for( i =4; i<n&&i>=0; i--)
{
printf("\n");
for(j=0; j<=i; j++)
printf("%d",j);

}

/*return to TC*/
getch();

return 0;
}

Is This Answer Correct ?    2 Yes 0 No

how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 0..

Answer / salvin

A much more simpler implementation....


public class Test
{
public static void main(String[] args)
{
int no=5;
for(int n=0;n<=no;n++){
for(int m=0;m<=n;m++){
System.out.print(m);
}
System.out.println();
}
for(int n=no;n>=0;n--){
for(int m=0;m<n;m++){
System.out.print(m);
}
System.out.println();
}
}
}

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

While compiling a c program,graphics header files are not including in my program..eg: <graphics.h>,what may be the problem...is there any environment settings exists.

2 Answers  


Explain what does a function declared as pascal do differently?

0 Answers  


What are # preprocessor operator in c?

0 Answers  


Average of a couple 10 years ago was 25. The average remains same after having a child and twins after 3 years. What is the present age of the first child

10 Answers   IBM, Infosys,


Should I learn c before c++?

0 Answers  


Define Array of pointers.

0 Answers  


What is that continue statement??

4 Answers  


Output for following program using for loop only * * * * * * * * * * * * * * *

3 Answers  


What is the difference between getch() and getche()?

1 Answers   NSPL,


Explain is it better to bitshift a value than to multiply by 2?

0 Answers  


struct tag{ auto int x; static int y; };main() { struct tag s; s.x=4; s.y=5; printf(ā€œ%dā€,s.x); }

2 Answers   Vector,


What are the key features of C?

6 Answers  


Categories