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
Multiply an Integer Number by 2 Without Using Multiplication Operator
Write a program to find the biggest number of three numbers in c?
What is pass by value in c?
Can you apply link and association interchangeably?
How can I sort more data than will fit in memory?
What is c token?
Differentiate between the expression “++a” and “a++”?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What is the difference between text and binary modes?
How pointer is different from array?
Why isnt there a numbered, multi-level break statement to break out
please explain every phase in the "SDLC" in the dotnet.
what is the height of tree if leaf node is at level 3. please explain
Why doesnt this code work?