Q. Write a C program to print the following star structure
*
**
* *
* *
* *
* *
* *
* *
* *
**********
Ans.
/*c program for star triangle frame pyramid*/
#include<stdio.h>
int main()
{
int num,r,j,sp;
printf("Enter no of rows: ");
scanf("%d", &num);
printf("\n*\n");
for(r=1; r<=num; r++)
{
printf("*");
for(sp=1; sp<r; sp++)
printf(" ");
printf("*\n");
}
for(j=1; j<=num+2; j++)
printf("*");
return 0;
}
The output of above program would be:
or
Q. Write a C program to print a triangle star frame.*
**
* *
* *
* *
* *
* *
* *
* *
**********
Ans.
/*c program for star triangle frame pyramid*/
#include<stdio.h>
int main()
{
int num,r,j,sp;
printf("Enter no of rows: ");
scanf("%d", &num);
printf("\n*\n");
for(r=1; r<=num; r++)
{
printf("*");
for(sp=1; sp<r; sp++)
printf(" ");
printf("*\n");
}
for(j=1; j<=num+2; j++)
printf("*");
return 0;
}
The output of above program would be:
Figure: Screen shot for star triangle frame pyramid C program |
it really works..thanku
ReplyDeletethaaanks a lot!
ReplyDelete#include
ReplyDelete#include
int main()
{
int i,j,k,l,m;
for(i=1;i<=8;i++)
{
for(j=1;j<=i;j++)
{
if(j==i||j==1)
printf("*");
else
printf(" ");
}
printf("\n");
}
for(j=1;j<8+2;j++)
printf("*");
}