write a pgm to print
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1

Answers were Sorted based on User's Feedback



write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / nisrar

void main()
{
int i,j,k,m;
for(i=1;i<=4;i++)
{
for(j=4;j>i;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
for(m=i;m>1;m--)
{
printf("%d",m-1);
}
printf("\n");
}
}

Is This Answer Correct ?    7 Yes 0 No

write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / siva kumar kalamraju

#include <stdio.h>
void fun(int num)
{
int i;
int max=1,spaces=0;

spaces=num*2;

while(max<=num)
{

for(i=1;i<=spaces;i++)
{
printf(" ");
}
for(i=1; i<=max; i++)
printf("%d ",i);
for(i=(max-1);i>0;i--)
printf("%d ",i);
printf("\n",i);
max++;
spaces=spaces-2;
}
//recursivefun(max+1);
}

int main()
{
int Number;
printf("Enter a Number:");
scanf("%d",&Number);
fun(Number);

getch();
}

Is This Answer Correct ?    5 Yes 4 No

write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1..

Answer / nisrar

void main()
{
int i,j,k,m;
for(i=1;i<=4;i++)
{
for(j=4;j>i;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
for(m=i;m>1;m--)
{
printf("%d",m-1);
}
printf("\n");
}
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

Why do we need volatile in c?

0 Answers  


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

0 Answers  


What is difference between && and & in c?

0 Answers  


What is a memory leak in structures? How can we rectify that?

2 Answers  


write a program to display the numbers having digit 9 in the given range from 1 to 100

1 Answers  






how does the for loop work actually..suppose for the following program how it ll work plz explain to me for(i=5;i>=0;i--) prinf(i--);

19 Answers   RMSI,


I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed

4 Answers   Aspire,


why programs in c are running with out #include<stdio.h>? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

0 Answers  


what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }

4 Answers  


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

1 Answers   TCS,


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1 Answers   IBM,


What is anagram in c?

0 Answers  


Categories