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

c++ Write a program that behaves as shown below: Here are the rules: Your progra

ID: 3700851 • Letter: C

Question

c++

Write a program that behaves as shown below:

Here are the rules:

Your program must use at least one for-loop.

Your program must output the parallelogram just one character at a time, inside a loop. (You will need nested loops.)

Your program must work with any length greater than 1. (You don't need to do any error checking for bad input)

Your program must use the character the user inputs to draw the parallelogram.

Hint: I recommend you think of this as a program to output two triangles, one above the other (the longest horizontal line is the border between the triangles).

Hint #2: To make this easier to solve, start by writing a program that outputs this text for the last example above:

After that is done, then figure out how to output the right number of characters.

Explanation / Answer

#include <iostream>

using namespace std;
int main() {
int n;
char ch;
cout<<"How long do you want each side to be? "<<endl;
cin >> n;
cout<<"Please enter the character you want it to be made of: "<<endl;
cin >> ch;
for(int i=1;i<=n;i++) {
for(int j=1;j<=i;j++){
cout<<ch;
}
cout<<endl;
}
for(int i=n-1;i>=1;i--){
for(int j=1;j<=i;j++){
cout<<ch;
}
cout<<endl;
}
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote