Write a program print squire pyramid using for loop.
quare Pyramid through For Loop:
#include<stdio.h>
#include<conio.h>
int main()
{
int colmn,rows,r,c,m;
printf("Enter no. of columns: ");
scanf("%d", &colmn);
printf("Enter no. of rows: ");
scanf("%d", &rows);
for(r=1; r<=colmn; r++)
if(r==1 || r==colmn)
printf(" ");
else
printf("*");
}
printf("\n");
for(c=1; c<=rows-2; c++)
{
printf("*");
for(m=1; m<=colmn-2; m++)
printf(" ");
printf("*\n");
}
for(r=1; r<=colmn; r++)
{
if(r==1 || r==colmn)
printf(" ");
else
printf("*");
}
getch();
}