/* Program to print the following output
*****
****
***
**
*
**
***
****
*****
*/
#include <stdio.h>
int main()
{
int i, j;
//Prints the upper part of the arrow
for(i=1; i<=5; i++)
{
//Prints trailing (2*rownumber-2) spaces
for(j=1; j<=(2*i-2); j++)
{
printf(" ");
}
//Prints inverted right triangle star pattern
for(j=i; j<=5; j++)
{
printf("*");
}
printf("\n");
}
//Prints lower part of the arrow
for(i=1; i<=5; i++)
{
//Prints trailing (2*5 - 2*rownumber) spaces
for(j=1; j<=(2*5 - 2*i); j++)
{
printf(" ");
}
//Prints simple right triangle star pattern
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
This comment has been removed by a blog administrator.
ReplyDelete