Thursday, January 1, 2015

pattern-1

1:
#include <stdio.h>

int main()
{
int row,star,n;
printf("please enter the number of lines:",n);
scanf("%d",&n);
for(row=1;row<=n;row++)
    {
    for(star=1;star<=row;star++)
    {
        printf("*");
    }
printf("\n");
    }
return 0;
}

input:7
output:
*
**
***
****
*****
******
*******

2:
#include <stdio.h>

int main()
{
int row,star,n;
printf("please enter the number of lines:",n);
scanf("%d",&n);
for(row=1;row<=n;row++)
    {
    for(star=n;star>=row;star--)
    {
        printf("*");
    }
printf("\n");
    }
return 0;
}

input:7
output:
*******
******
*****
****
***
**
*


No comments:

Post a Comment