Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

3. Discuss the process of behavior modeling training.

Answered: 1 week ago