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

Declare variables for outer counter, inner counter, size offigure Initialize cou

ID: 3615317 • Letter: D

Question

Declare variables for outer counter, inner counter, size offigure

Initialize counters to 0

Start outer loop to count up the lines

Start inner loop to count up the number of *

Start outer loop to count down the lines

Start inner loop to count down the number of *

Final pattern

*

**

***

****

*****

****

***

**

*

#include <iostream>

using namespace std;

const int HEIGHT = 5;

int main()

{  

    int i = 0, j = 0;

    cout << endl;

    while (i < HEIGHT)

   {         

          i++;

          j =0;

          while (j< i)

          {

             j++;

             cout << "*" ;

          }

          cout<< endl;

    }

while (i > 0)

   {         

          i--;

          j =0;

          while (j< i)

          {

             j++;

             cout << "*" ;

          }

          cout<< endl;

    }

    system("PAUSE");

    return 0;  

}

Explanation / Answer

//Here is the programwithout counter while loop. //Hope this will helpyou.


#include <iostream> using namespace std; const int HEIGHT = 5; int main() {    int i = 0, j = 0,h;    cout << endl;    while (i < HEIGHT*2)    {    if(i<HEIGHT)      h=i%HEIGHT;    else    {    h= HEIGHT - i%HEIGHT;    }    i++;    j = 0;    while (j < h)    {      j++;    cout<< "*" ;    }    cout <<endl;    }       system("PAUSE");    return 0; }
#include <iostream> using namespace std; const int HEIGHT = 5; int main() {    int i = 0, j = 0,h;    cout << endl;    while (i < HEIGHT*2)    {    if(i<HEIGHT)      h=i%HEIGHT;    else    {    h= HEIGHT - i%HEIGHT;    }    i++;    j = 0;    while (j < h)    {      j++;    cout<< "*" ;    }    cout <<endl;    }       system("PAUSE");    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