Question: Programming Problems The following C code allows the user to draw a half pyramid of n number of rows using the * character. The minimum

Programming Problems

The following C code allows the user to draw a half pyramid ofnnumber of rows using the * character. The minimum and the maximum number of rows are2and10respectively.

#include intmain() { introws =0; do{ printf("please enter the number of rows: "); scanf("%d",&rows); }while(rows ); printf("printing a half pyramid of %d rows", rows); printf(" ");

for(inti =1; i ;> for(intj =1; j =rows;> printf("* "); } } return0; }

Questions

Q1] Compile and run the code as it is, and report any problem you noticed

Q2] Fix the code, so that the user can use it to print a half pyramid of n number of rows using the * character, remember the minimum and the maximum number of raws are 2 and 10 respectively.

Q3] After fixing the code could you modify the code to rather than using the * character it uses numbers when drawing the pyramid as showing in the sample outputs 3 and 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!