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

Write a console application that uses for-loops to display the following pattern

ID: 3646218 • Letter: W

Question


Write a console application that uses for-loops to display the following patterns separately, one below the other.


*
**
***
****
*****
******
*******
********
*********
**********

**********
*********
********
*******
******
*****
****
***
**
*

**********
*********
********
*******
******
*****
****
***
**
*

*
**
***
****
*****
******
*******
********
*********
**********

Use for loops to generate the patterns. All asterisks ( * ) should be printed by a single statement of the form cout "'*"; which causes the asterisks to print side by side. A statement of the form endl or " " can be used to move to the next line. A statement of the form cout << " "; can be used to display a space for the last two patterns. There should be no other output statements in the application.. (Hint: The last two patterns require that each line begins with an appropriate number of blank spaces.)




This is the code...hope it will help to make flowchart.thanks
#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

int i,j;
for(i=0;i<10;i++)
{
for(j=0;j<i;j++)
cout<<"*";
cout<<" ";
}
cout<<" ";
for(j=10;j>0;j--)
{
for(i=0;i<j;i++)
cout<<"*";
cout<<" ";
}
cout<<" ";
for(j=10;j>0;j--)
{
for(i=0;i<j;i++)
cout<<"*";
cout<<" ";
}
cout<<" ";
for(i=0;i<10;i++)
{
for(j=0;j<i;j++)
cout<<"*";
cout<<" ";
}
return 0;

}

Explanation / Answer

Flowchart:
For 1st loop
i=0;
j=0 only
Output:*
i=1;
j=0,1
Output:**
i=2;
j=0,1,2
Output:***

and so on.

For 2nd loop

j=10

i=0 to 9

Output:**********

j=9

i=0 to 8

Output:*********

and so on

For 3rd loop:same as 2nd loop

For 4th loop:same as 1st loop

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