Algorithm for star pyramid
Q. Write a C program to print the following star program. Also write down the algorithm.
*
**
***
****
*****
Ans.
C program for above star pyramid at:
click here
Algorithm for above star pyramid as follows:
[star pyramid procedure]
step1: Start
step2: Read number num
step3: [initialize]
r=1
step4: Repeat step 4 through 10 until num>=r
step5: [initialize]
c=1
step6: Repeat step 6 through 8 until c<=r
step7: print */#
step8: c=c+1
[end of loop step6]
step9: go to next line
step10: r=r+1
[end of loop step4]
step11: stop
[end of star pyramid procedure]
*
**
***
****
*****
Ans.
C program for above star pyramid at:
click here
Algorithm for above star pyramid as follows:
[star pyramid procedure]
step1: Start
step2: Read number num
step3: [initialize]
r=1
step4: Repeat step 4 through 10 until num>=r
step5: [initialize]
c=1
step6: Repeat step 6 through 8 until c<=r
step7: print */#
step8: c=c+1
[end of loop step6]
step9: go to next line
step10: r=r+1
[end of loop step4]
step11: stop
[end of star pyramid procedure]
No comments:
Post a Comment