## 7.07.2012

### Number triangle

Q. Write a C program to print the following number triangle or structure:

1
21
321
4321
54321

Ans.

/*c program code for number pyramid*/
#include<stdio.h>
int main()
{
int num,r,c,sp;
printf("Enter number of rows: ");
scanf("%d", &num);
for(r=1; r<=num; r++)
{
for(sp=num-r; sp>0; sp--)
printf(" ");
for(c=r; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
return 0;
}

/****************Output**************/

 Screen shot for number triangle C program

1. sir how can we do this
*****5
****54
***543
**5432
*54321

1. #include
#include
void main()
{
int n,r,c,s;
clrscr();
printf("enter loop repeat number");
scanf("%d",&n);
for(r=n;r>=1;r--)
{
for(s=1;s<=r;s++)
printf("*");
for(c=n;c>=r;c--)
printf("%d",c);
printf("\n");
}
getch();
}

2. 1
2 1 2
3 2 1 2 3
4 3 2 12 3 4 iwant java code for this triangle

3. ****1
***21
**321
*4321
54321
i want in php code

4. wat is the c code for_
1
21
321
4321
54321

1. @ Saks#!

Your required number triangle pyramid C program source code at:

http://cprogrammingcodes.blogspot.com/2011/09/14design-numbers-tringle-pyramid.html

5. 5 4 3 2 1
4 3 2 1
3 2 1
2 1
1

1. @Sagar Kacharia,

Number Triangle Pyramid Pattern C program source code :

http://cprogrammingcodes.blogspot.com/2011/09/13design-numbers-tringle-pyramid.html

6. could you do this?
01234
10123
21012
32101
43210

1. #Alit

Thanks for comments, your required number triangle C program source code as:

#include"stdio.h"
int main()
{
int r,c,num=5;
for(r=0; r=0; c--)
printf(" %d",c);
for(c=1; c<num-r; c++)
printf(" %d",c);
printf("\n");
}
return 0;
}

/***** OUTPUT******/
01234
10123
21012
32101
43210