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

Multiply an Integer Number by 2 Without Using Multiplication Operator

769


Write a program to find the biggest number of three numbers in c?

1051


What is pass by value in c?

1074


Can you apply link and association interchangeably?

1125


How can I sort more data than will fit in memory?

1115


What is c token?

1074


Differentiate between the expression “++a” and “a++”?

1256


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

1082


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1096


What is the difference between text and binary modes?

1197


How pointer is different from array?

1088


Why isnt there a numbered, multi-level break statement to break out

1057


please explain every phase in the "SDLC" in the dotnet.

2622


what is the height of tree if leaf node is at level 3. please explain

2153


Why doesnt this code work?

1069