C program to print triangle as shown below:
For N=5, print output as
* * * * *
* * * *
* * *
* *
*
#include<stdio.h>
int main()
{
int i,j,n=5;
for(j=0; j<n; j++)
{
for(i=n; i>n-j; i--)
printf(" ");
for(i=0; i<n-j; i++)
printf("* ");
printf("\n");
}
return 0;
}
For N=5, print output as
* * * * *
* * * *
* * *
* *
*
#include<stdio.h>
int main()
{
int i,j,n=5;
for(j=0; j<n; j++)
{
for(i=n; i>n-j; i--)
printf(" ");
for(i=0; i<n-j; i++)
printf("* ");
printf("\n");
}
return 0;
}
No comments:
Post a Comment