write a pgm to print
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
Answer Posted / 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 |
Post New Answer View All Answers
Can we use any name in place of argv and argc as command line arguments?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
Explain the bubble sort algorithm.
What is memory leak in c?
how to find binary of number?
Define the scope of static variables.
What is the use of volatile?
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
What is the size of enum in bytes?
What is hashing in c?
What is omp_num_threads?
Why can’t constant values be used to define an array’s initial size?
What is operator precedence?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Is it fine to write void main () or main () in c?