C Programming

C Programming


Number Triangle Pattern C Program

Posted: 09 Aug 2014 09:47 AM PDT

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

0
101
21012
3210123
432101234
54321012345

Ans.

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

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

/*************************************************************
The output of above number triangle pattern program as
************************************************************/

Output for Number Triangle Pattern C Program
Figure: Screen shot for Number Triangle Pattern C program

You might also like:

  1. 110+ C Pyramid Triangle Pattern C Programs


Post a Comment