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

find the minimum of three values inputted by the user

3 Answers  


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

0 Answers  


What is an example of structure?

0 Answers  


What Is The Difference Between Null And Void Pointer?

0 Answers   TCS,


What are pointers in C?

5 Answers   KPIT,






how 2 compile & execute c program with out using editor?

2 Answers   HP,


#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

0 Answers  


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


what is constant pointer?

3 Answers  


write a program to search for an element in a given array. If the array was found then display its position otherwise display appropriate message in c language

18 Answers   IT Park, TCS,


Why do we need functions in c?

0 Answers  


1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā€œ%dā€,x); --x; } }

7 Answers   CSC,


Categories