Write a C program to display a triangle of digits as follows. Number of rows is entered by keyboard....



          1

               2  2

             3  3  3

           4  4  4  4

         5  5  5  5  5

             6  6  6  6  6  6


#include<stdio.h>
 int main()
   {
     int  i, j, sp, n;
     printf( "How many line: " );
     scanf( "%d" ,&n);
     for(i=1;i<=n;i++)
        {
          printf( "\n" );
          for(sp=n+1;sp>i;sp--)
             printf( " " );
          for(j=1;j<=i;j++)
             printf( "%2d" ,i);
         }

      return 0;
   }

No comments:

Post a Comment