Q. write a c program to print the following star rectangle design:
********
* *
* *
********
Ans.
/*c program for star rectangle design*/
#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++)
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++)
printf("*");
getch();
return 0;
}
The output of above program would be:
********
* *
* *
********
Ans.
/*c program for star rectangle design*/
#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++)
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++)
printf("*");
getch();
return 0;
}
The output of above program would be:
Figure: Screen shot of Rectangle Star pyramid C program |
plz also uplod fo c#
ReplyDeleteplz upload M pattern in c.
ReplyDelete@Amit Gupta,
DeleteThe M design pattern program in C source code is:
http://cprogrammingcodes.blogspot.com/2014/09/how-to-print-m-shape-pyramid-in-c.html