Pattern 24 : C Program to print triangle Number pattern using for loops

Spread the love

Write a C Program to print below number pattern on the console:

Enter how many rows you want: 5
 1
 1 2
 1 2 3
 1 2 3 4
 1 2 3 4 5

Program:

  1. /*
  2.    C Program to print triangle number pattern on Console
  3.    Author : Venkatesh Macha
  4.    Website : www.SillyCodes.com
  5. */
  6. #include<stdio.h>
  7. int main()
  8. {
  9.    int i,j,k,n;
  10.    printf(“Enter how many rows you want : “);
  11.    scanf(“%d”,&n);
  12.  
  13.    for(i=1;i<=n;i++)
  14.    {
  15.       for(j=1;j<=i;j++)
  16.          printf(” %d”,j);
  17.  
  18.       printf(n);
  19.    }
  20.    return 0;
  21. }

Output:

Similar Number Patterns:

Similar Star pattern programs :

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply