C Program to Print Triangle of Numbers – Part 1

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.

yashan has written 70 articles

18 thoughts on “C Program to Print Triangle of Numbers – Part 1

    1. sriram says:

      #include
      main()
      {
      int i,j,k,n;

      printf(“Enter number of rows of the triangle \n”);
      scanf(“%d”,&n);

      for(i=1;i<=n;i++)
      {

      for(k=1;k<=(2*i)-1;k++)
      {
      j=i;
      printf("%d",j);
      j++;
      }
      printf("\n");
      }
      getch();
      }

    2. Ashok kumar srivastava says:

      #include

      int main()
      {
      int n, i, c, a = 1;

      printf(“Enter the number of rows of Floyd’s triangle to print\n”);
      scanf(“%d”, &n);

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

      return 0;
      }

    1. Latisha says:

      Pystyykö ukkosen etäisyyden laskea laskemalla sekunteja välähdyksestä ja jakamalla sitten kolmella??eli jos välähtää ja siitä noin 9 sekunnin päästä kuuluu jyrinä niin ukkonen on noin kolmen kilometrin päässä…näin joskus jostain opnsnkuulii..=)vi/siin valon nopeuteen 300000m/s liittyvä juttu??

    2. http://www./ says:

       ( 2012.03.6 17:48 ) : My partner and I stumbled over here different page and thought I may as well check things out. I like what I see so now i am following you. Look forward to checking out your web page for a second time.

    3. I know how difficult this has been for you…and I know that the Lord fills our cups to overflowing because He wants us to rely on Him. With our mutual situations, we have to trust His sovereign plan for our families and rest in the comfort that He loves us and our children more than we can possibly comprehend. I’m praying for you! Drink fully and confidently and rest peacefully in His grace.

Cancel reply

Leave a Reply to aliza eshaal

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>