I need to add a call to the PrintLine function of this code:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need to add a call to the PrintLine function of this code: 

#include <stdio.h>

//function prototypes
void PrintLine(int length, char theChar);
void PrintRectangle(int width, int height, char theChar);
void PrintTriangle(int baseLength, char theChar);
void PrintInvertedTriangle(int height, char theChar);
void PrintPyramid(int height, char theChar);

int main(void)

{

char choice;
int a, b;
char character;

//asking for user input
printf("Which shape (L-line, T-triangle, R-rectangle, I-inverted triangle, P-pyramid): \n");
scanf(" %c", &choice);
printf("Which character: \n");
scanf(" %c", &character);
switch (choice)
{

//if user input is for a triangle
case 'T':
case 't':
printf("Enter an integer base length between 3 and 25: \n");
scanf("%d", &a);
if (a >= 3 && a <= 25)
PrintTriangle(a, character);
else
printf("Length not in range.");
break;

//if user input is for a rectangle
case 'R':
case 'r':
printf("Enter an integer width and height between 2 and 25: \n");
scanf("%d%d",&a, &b);
if((a<2 || a>25 )){
printf("Width not in range.");
break;
}

if((b<2||b>25)){
printf("Height not in range.");
break;
}

if(a >= 2&&a<=25 && b>=2&&b<=25)
PrintRectangle(a, b, character);
break;

//if user input is a line
case 'L':
case 'l':
printf("Enter an integer length between 1 and 25: \n");
scanf("%d", &a);
if (a >= 1 && a <= 25)
PrintLine(a, character);
else
printf("Length not in range.");
break;

//if user input is an inverted triangle
case 'i':
case 'I':
printf("Enter an integer base length between 2 and 25: \n");
scanf("%d", &a);
if (a >= 2 && a <= 25)
PrintInvertedTriangle(a, character);
else
printf("Height not in range.");
break;

//if user input is a pyramid
case 'P':
case 'p':
printf("Enter an integer width between 2 and 25: \n");
scanf("%d", &a);
if (a >= 2 && a <= 25)
PrintPyramid(a, character);
else
printf("Width not in range.\n");
break;

//if user input isn't a line, rectagnle, triangle, inverted triangle, or pyramid
default:
printf("Unknown shape.\n");
break;
}
}

//line function
void PrintLine(int length, char theChar)
{
int i;
for (i = 0; i < length; i++)
printf("%c", theChar);
printf("\n");
}

//triangle function
void PrintTriangle(int baseLength, char theChar)
{
int i, j;
for (i = 1; i <= baseLength; i++)
{
for (j = 0; j < i; j++)
printf("%c", theChar);
printf("\n");
}
}

//rectangle function
void PrintRectangle(int width, int height, char theChar)
{
int i, j;
for (i = 0; i < height; i++)
{
for (j = 0; j < width; j++)
printf("%c", theChar);
printf("\n");
}
}

//inverted triangle function
void PrintInvertedTriangle(int height, char theChar)
{
int i;
for (i = height; i > 0; i--)
{
PrintLine(i, theChar);
}
}

//pyramid function
void PrintPyramid(int width, char theChar)
{
PrintTriangle(width, theChar);

PrintInvertedTriangle(width-1, theChar);
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education