Equal Number Triangle

Q. Write a C program to print the following equal number triangle pattern as:

1
212
32123
4321234
543212345

Ans.

/*c program for equal number triangle pattern*/
#include<stdio.h>
int main()
{

 int num,r,c;
 printf("Enter Any Number : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
   for(c=r; c>=1; c--)
      printf("%d",c);
   for(c=2; c<=r; c++)
      printf("%d",c);
   printf("\n");
 }
 getch();
 return 0;
}

/**********************************************************
The output of above program would be:
***********************************************************/

Output of equal number triangle pattern C program
Figure: Screen shot for equal number triangle C program

Related Programs:

Equal Character Triangle as:

A
BAB
CBABC
DCBABCD

Comments