Ex: Write a C Program To Print inverted Pyramid star pattern. How to write a C Program To Print inverted Pyramid star pattern. C Program To Print inverted Pyramid star pattern.
Input from user:
Enter the number:
7
Expected output:
*******
******
*****
****
***
**
*
Step by step logic of the given program:
1. Accept input(number) from user which shows number of rows, declare variable say no.
2. Run one outer loop from 1 to no:
for(i=1;i<=no;i++)
3. To print spaces run another for loop from 1 to i-1:
for(j=1;j<i;j++)
printf(" ");
4. To print star use another one inner for loop from i to no:
for(k=i;k<=no;k++)
printf(" *");
5. For new row, move to next line using \n.
No comments:
Post a Comment
If you have any doubts, please discuss here...👇