Pattern 3:
Discussion:
This code print stars like Pyramid. This is user input code using scanf().
Code:
#include <stdio.h>
int main()
{
int i,j,k, n;
printf("how many row you want : ");
scanf("%d", &n);
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
printf(" ");
}
for(k=1;k<(2*i);k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Post a Comment