Q. Write a C program to print the following star pattern.
*
***
******
Ans.
/*c program for print the specific star structure*/
#include<stdio.h>
int main()
{
int n=2,r,c;
printf("*\n");
for(r=1; r<=2; r++)
{
for(c=1; c<=r*3; c++)
printf("*");
printf("\n");
}
return 0;
}
The output of above program would be:
or
Q. Write a C program to print the following star structure.*
***
******
Ans.
/*c program for print the specific star structure*/
#include<stdio.h>
int main()
{
int n=2,r,c;
printf("*\n");
for(r=1; r<=2; r++)
{
for(c=1; c<=r*3; c++)
printf("*");
printf("\n");
}
return 0;
}
The output of above program would be:
Figure: Screen-shot for star triangle/pyramid C program |
No comments:
Post a Comment