Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble getting my program to print shapes For example: Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25:

I'm having trouble getting my program to print shapes

For example:

Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25: 13 *************

Which shape (L-line, T-triangle, R-rectangle): t Enter an integer base length between 3 and 25: 5 * ** *** **** *****

Which shape (L-line, T-triangle, R-rectangle): r Enter an integer width and height between 2 and 25: 4 5 **** **** **** **** ****

Here's my code:

#include

#include

const int MAX_DIMENSION = 25;

void printLine(int length){

scanf("%d", &length);

for(int i=0; i

if(length<0 && length>25){

printf("That input is invalid.");

else{

printf("*");

}

}

}

}

void printTriangle(int baseLength){

scanf("%d", &baseLength);

for(int i=0; i

if(length<3 && length>25){

printf("That input is invalid.");

else{

printf("*");

}

}

}

}

void printRectangle(int width, int height){

scanf("%d %d", &width, &height);

for(int i=0; i

for(int j=0; j

if((width<2 && width>25) && (height<2 && height>25){

printf("That input is invalid.");

else{

printf("*");

}

}

}

}

}

int main() {

char option;

printf("Which shape (L-line, T-triangle, R-rectangle): ");

scanf("%c", &option);

option = toupper(option);

printf(" ");

switch (option) {

case 'L' || case 'l':

printf("Enter an Integer length between 1 and 25");

printLine();

break;

case 'T' || case 't':

printf("Enter an Integer base length between 3 and 25");

printTriangle();

break;

case 'R'|| case 'r':

printf("Enter an Integer width and height between 2 and 25");

printRectangle();

break;

default:

break;

}

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions