Question: This is exactly what I have in my program but there is errors I don't know what I am doing wrong #include void pyramid() {

This is exactly what I have in my program but there is errors I don't know what I am doing wrong

#include void pyramid() { int i, space, rows, star=0; printf("Please type in the height of the pyramid"); printf("It must be at least 1 high and no more than 25 : "); scanf("%d",&rows); /* printing one row in every iteration */ for(i = 1; i <= rows; i++) { /* Printing spaces */ for(space = 1; space <= rows-i; space++) { printf(" "); } /* Printing stars */ while(star != (2*i - 1)) { printf("*"); star++;; } star=0; /* move to next row */ printf(" "); } } void diamond() {

int i, space, rows=7, star=0; /* Printing upper triangle */ for(i = 1; i <= rows; i++) { /* Printing spaces */ for(space = 1; space <= rows-i; space++) { printf(" "); } /* Printing stars */ while(star != (2*i - 1)) { printf("*"); star++;; } star=0; /* move to next row */ printf(" "); } rows--; /* Printing lower triangle */ for(i = rows;i >= 1; i--) { /* Printing spaces */ for(space = 0; space <= rows-i; space++) { printf(" "); } /* Printing stars */ star = 0; while(star != (2*i - 1)) { printf("*"); star++; } printf(" "); } } int main() { int a=0; printf("Enter Yes to print diamond Enter No to print Pyramid Enter your choice :"); scanf("%d",&a); if(a==Yes) diamond(); else if(a==No) pyramid(); else printf(" Wrong Input"); return 0; }

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 Databases Questions!