Firstly we will take a for loop(outer) for no of rows.
Print spaces
For every ith row , print n-i spaces.
Print letters
For every ith row , print i letters.Also remember letters are printed in descending order.
#include<stdio.h>
int main()
{
int i,j,n;
printf("Enter number of rows ");
scanf("%d",&n);
for(i=65;i<=68;i++)
{
for(j=i;j<68;j++)
printf(" ");
for(j=i;j>=65;j--)
printf("%c",j);
printf("\n");
}
return 0;
}
No comments:
Post a Comment