Posted by : Unknown
Wednesday, February 3, 2016
****
* *
* *
* *
****
Ans:
#include<stdio.h>
int main()
{
int cols,rows,r,c,sp;
printf("Enter no. of columns: ");
scanf("%d", &cols);
printf("Enter no. of rows: ");
scanf("%d", &rows);
for(r=1; r<=cols; r++)
{
if(r==1 || r==cols)
printf(" ");
else
printf("*");
}
printf("\n");
for(c=1; c<=rows-2; c++)
{
printf("*");
for(sp=1; sp<=cols-2; sp++)
printf(" ");
printf("*\n");
}
for(r=1; r<=cols; r++)
{
if(r==1 || r==cols)
printf(" ");
else
printf("*");
}
getch();
return 0;
}
int main()
{
int cols,rows,r,c,sp;
printf("Enter no. of columns: ");
scanf("%d", &cols);
printf("Enter no. of rows: ");
scanf("%d", &rows);
for(r=1; r<=cols; r++)
{
if(r==1 || r==cols)
printf(" ");
else
printf("*");
}
printf("\n");
for(c=1; c<=rows-2; c++)
{
printf("*");
for(sp=1; sp<=cols-2; sp++)
printf(" ");
printf("*\n");
}
for(r=1; r<=cols; r++)
{
if(r==1 || r==cols)
printf(" ");
else
printf("*");
}
getch();
return 0;
}
**********OUTPUT**********
****
* *
* *
* *
****
*************************
Related Posts :
- Back to Home »
- Star Patterns »
- 31.Square Star Pyramid using *'s as shown below.