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

Ask the user for an integer between 1 and 99. Based on the user input print the

ID: 3535462 • Letter: A

Question

Ask the user for an integer between 1 and 99. Based on the user input print the following patterns. NOTE: You may not hard code the patterns and you MUST use loops to print them. Otherwise no credit will be given for the problem.

For example, if the user enters 7 the patterns will look like:

Pattern 1:
+++++++
+++++++
+++++++
+++++++
+++++++
+++++++
+++++++

Pattern 2:
+
++
+++
++++
+++++
++++++
+++++++

Pattern 3:
+++++++
++++++
+++++
++++
+++
++
+

If the user enters 10 the patterns will look like:

Pattern 1:
++++++++++
++++++++++
++++++++++
++++++++++
++++++++++
++++++++++
++++++++++

Pattern 2:
+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++

Pattern 3:
++++++++++
+++++++++
++++++++
+++++++
++++++
+++++
++++
+++
++
+
.

Explanation / Answer

#include <iostream>

using namespace std;

int main(){

int n;

cout << "Printes three patterns."<<endl << endl;

cout << "Enter a number: ";

cin >> n;

cout << "Pattern 1:" << endl << endl;

for(int i = 0; i < n; ++i){


for(int j = 0; j < n; ++j){

cout << '+';

}

cout << endl;

}

cout << "Pattern 2:" << endl << endl;

for(int i = 0; i < n; ++i){

for(int j = 0; j <= i; ++j){

cout << '+';

}

cout << endl;

}

cout << "Pattern 2:" << endl << endl;

for(int i = n; i > 0; --i){

for(int j = 0; j < i; ++j){

cout << '+';

}

cout << endl;

}

return 0;

}

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