1:
#include<stdio.h>
int main()
{
int row,space,star,n;
printf("please enter the number of lines:");
scanf("%d",&n);
for(row=n;row>=1;row--)
{
for(space=0;space<row;space++)
{
printf(" ");
}
for(star=n;star>=row;star--)
{
printf("*");
}
printf("\n");
}
return 0;
}
input: 7
output:
*
**
***
****
*****
******
*******
2:
#include<stdio.h>
int main()
{
int row,space,star,n;
printf("please enter the number of lines:");
scanf("%d",&n);
for(row=n;row>=1;row--)
{
for(space=n;space>row;space--)
{
printf(" ");
}
for(star=1;star<=row;star++)
{
printf("*");
}
printf("\n");
}
return 0;
}
input: 7
output:
*******
******
*****
****
***
**
*
No comments:
Post a Comment