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

Pattern Displays Write a program that uses either a while or do while loop to di

ID: 1923015 • Letter: P

Question

Pattern Displays

Write a program that uses either a while or do while loop to display Pattern A below, followed by another loop that displays Pattern B.

Pattern A
+
++
+++
++++
+++++
++++++
++++++++
+++++++++
++++++++++

Pattern B
++++++++++
+++++++++
++++++++
+++++++
++++++
+++++
++++
+++
++
+

 

here's the code with for loops. I get stuck trying to flip it over to a while or do while loop

#include<iostream>
using namespace::std;
int main(){
int n;
cout<<"Enter the triangle's dimensions ";
cin>>n;
for (int i = 1 ; i <= n ; i++){
for (int j=1; j<=i ; j++){
cout<<"*";
}//end for
cout<<" ";
}//end for
cout<<" ";

for(int i=n; i>=1; i--){
for(int j=i; j>=1; j--){
cout<<"*";
}//end for
cout<<" ";
}//end for
return 0;

}//end main

Explanation / Answer

int main(){ int i,j,n; coutn; cout