i want the code for printing the output as follows

4 4
3 3
2 2
1 1
0
1 1
2 2
3 3
4 4

Answers were Sorted based on User's Feedback



i want the code for printing the output as follows 4 4 3 3 2 2 1 1 ..

Answer / vignesh1988i

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

thank u

Is This Answer Correct ?    2 Yes 0 No

i want the code for printing the output as follows 4 4 3 3 2 2 1 1 ..

Answer / shafi dayatar

#include<stdio.h>

int main(){

int i=0,j=0;
for(i=0;i<9;i++){
for(j=0;j<9;j++){

if( i==j || i+j==8)
if(i<=4)
printf("%d",4-i);
else
printf("%d",i-4);
else
printf(" ");
}
printf("\n");
}

return 0;

}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

What are the similarities between c and c++?

0 Answers  


What does a run-time "null pointer assignment" error mean?

2 Answers  


create an SINGLE LINKED LISTS and reverse the data in the lists completely

3 Answers  


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

0 Answers  


Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter words-1 3-letter words-1 4-letter words-4

1 Answers   Mind Tree, TCS,






Why do we use & in c?

0 Answers  


what is a void pointer?

2 Answers  


Explain how can a program be made to print the line number where an error occurs?

0 Answers  


what are brk, sbrk?

1 Answers   Oracle,


What is a memory leak? How to avoid it?

1 Answers  


f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c?

5 Answers   Geometric Software,


what is data structure

5 Answers   Maveric, TCS,


Categories