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
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
Why dont c comments nest?
What is string length in c?
What is structure of c program?
When is a “switch” statement preferable over an “if” statement?
What is %d used for?
what value is returned to operating system after program execution?
Describe wild pointers in c?
which is conditional construct a) if statement b) switch statement c) while/for d) goto
Explain high-order bytes.
Why do we use header files in c?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What is a const pointer?
What is the role of this pointer?