write a program for
4 4
3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3
4 4



write a program for 4 4 3 3 3 3 2 2 2 2 ..

Answer / vidyullatha

#include<stdio.h>

main()
{
int i=0,k=0,l=0;
int cnt=1;
int space=7;
for (i=4;i>0;i--)
{
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
for(k=0;k<space;k++)
{
printf(" ");
}
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
cnt++;
space=space-2;
printf("\n");
}
for(i=0;i<9;i++)
{
printf("0 ");
}
printf("\n");
cnt=4;
space=1;
for(i=1;i<=4;i++)
{
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
for(k=0;k<space;k++)
{
printf(" ");
}
for(l=1;l<=cnt;l++)
{
printf("%d ",i);
}
cnt--;
space=space+2;
printf("\n");
}
}

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C Interview Questions

What is the memory allocated by the following definition ? int (*x)[10];

4 Answers   ADITI, Wipro,


Write a C program to perform some of the operation which can be performed using Single linked list

1 Answers   Qualcomm,


write a program for even numbers?

19 Answers   TCS,


What is the size of enum in c?

0 Answers  


How can I use a preprocessorif expression to ?

0 Answers  






What is the difference between malloc calloc and realloc in c?

0 Answers  


void main() { int *ptr; ptr = (int *) 0x400 ; printf("ptr=%d",ptr); } output?

1 Answers  


Tell me what are bitwise shift operators?

0 Answers  


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


Explain how are portions of a program disabled in demo versions?

0 Answers  


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

0 Answers  


Where is volatile variable stored?

0 Answers  


Categories