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

input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure

4 Answers   IBM,


Tell us something about keyword 'auto'.

0 Answers  


Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse to it. eg:123 output:123321 (or) 12321

7 Answers   HCL,


to find out the reverse digit of a given number

6 Answers   Infosys, Microsoft, TCS, Wipro,


difference between object file and executable file

0 Answers  






#include<stdio.h> int main( ) { Int a=300, b, c; if(a>=400) b=300; c=200; printf(“%d%d ”, b, c); return0; }

1 Answers  


What is void main ()?

0 Answers  


How can we see the Expanded source code and compiled code for our source program in C?

1 Answers  


while initialization of array why we use a[][2] why not a[2][]...?

0 Answers   Aptech,


what is the coding of display the factorial of a number using array and function?

1 Answers  


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

0 Answers  


program for following output using for loop? 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

8 Answers   Aptech, Infosys,


Categories