Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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?

2065


Why dont c comments nest?

1001


What is string length in c?

1029


What is structure of c program?

1082


When is a “switch” statement preferable over an “if” statement?

1074


What is %d used for?

993


what value is returned to operating system after program execution?

2067


Describe wild pointers in c?

1064


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1168


Explain high-order bytes.

1063


Why do we use header files in c?

1021


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

1186


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1676


What is a const pointer?

1043


What is the role of this pointer?

995