Skip to content

C Program to Print Triangle of Numbers – Part 1

by yashan on August 30th, 2011

Write a program in the C programming language to print the triangle of numbers. Make a C program to print the following right angled triangle-


1
12
123
1234
12345
123456
1234567
12345678
123456789


Make this program by using the nested for loop. Below is the solution of the program.-

void main()
{
     int n, i;

     for(i=1 ;i<=9; i++)
     {
             for(n=1; n<=i; n++)
             {
                     printf("%d",n);
             }
             printf("\n");
     }
     getch();
}

Output – Output of the program will be same as the triangle made above.

One Comment
  1. karthika permalink

    1
    2 3 4
    5 6 7 8 9

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS