Sunday, 18 September 2016

Number pattern : Pyramid of square of 1 to 25

                  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>

int 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");
}
return 0;
}

No comments:

Post a comment