Q. Write a C program to make the following star triangle as:
*
**
**
**
******
Ans.
/*c program for star triangle design*/
#include<stdio.h>
int main()
{
int r,c,n;
printf("*\n");
for(r=1; r<=4; r++)
{
if(r<=3)
{
for(c=1; c<=2; c++)
printf("*");
}
else
{
for(c=1; c<=6; c++)
printf("*");
}
printf("\n");
}
getch();
return 0;
}
/*************************************************************
*
**
**
**
******
Ans.
/*c program for star triangle design*/
#include<stdio.h>
int main()
{
int r,c,n;
printf("*\n");
for(r=1; r<=4; r++)
{
if(r<=3)
{
for(c=1; c<=2; c++)
printf("*");
}
else
{
for(c=1; c<=6; c++)
printf("*");
}
printf("\n");
}
getch();
return 0;
}
/*************************************************************
The output of above program would be:
**************************************************************/Figure : Screen shot for star triangle C program |
Comments
Post a Comment