Number Patterns Example 18 – C Program

Number Patterns Example 18 – C Program

write a c program to display triangle number patterns example shows like below patterns.

                                1
                          4   9  16
                  25  36  49  64  81
        100 121 144 169 196 225 256
289 324 361 400 441 484 529 576 625

#include <stdio.h>
#include<conio.h>

void main()
{
    int i, j, k=1;

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

getch();
}            

The output of number patterns c program is :

               1  
           4   9  16
       25  36  49  64  81
    100 121 144 169 196 225 256
289 324 361 400 441 484 529 576 625

 

Leave a Reply

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