Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Ask the user to input a character. You will draw your right triangle with th

ID: 3695294 • Letter: C

Question

C++

Ask the user to input a character. You will draw your right triangle with this character. Ask the user to input the number of rows (integer). This will also signify the number of characters at the top of the triangle. Use a nested loop to draw the triangle. The first line will now have the same number of characters as there are rows and the number of characters on each line will decrease by one until you have reached the base of your triangle. Include spaces between each character. Ex. Enter a character: * Enter number of rows: 7

Explanation / Answer

#include<iostream.h>

#include<coonio.h>

void main() {

int rows,i,j;

char 'c';

cout<< "Enter a character :";

cin>>c;

cout<<" Enternumber of rows :";

cin>>rows;

for(i=rows; i>=1; i--) {

for(j=i; j>=1; j--) {

cout<<"c";

}

cout<<end1;

}

return 0;

}