Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming: Create a function named printTriangleFor. The function should take an integer as a parameter for height and print a triangle of plusses and

C Programming:

Create a function named printTriangleFor. The function should take an integer as a parameter for height and print a triangle of plusses and dashes as shown below to the screen using only FOR loops. Do not use WHILE loops. If a value less than 1 is passed as an argument, the function should not print anything. The triangle should be printed with only spaces, dashes (minus), plus signs, and newlines. Each line should end with a newline. There should be spaces before the first plus sign and no spaces after the last plus sign. There should be no extra characters anywhere else. For example: printTriangle(7); should print a seven level triangle as shown below (note the height and width are both 7)

This function should be executed be another file like this:

image text in transcribed

Here is the main that runs it:

#include

//Sample main.cc

void printTriangleFor(int);

int main() {

printTriangleFor(7);

}

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

More Books

Students also viewed these Databases questions