0

Hi.... I'm a beginner at this programming thing and I need some help using nested for loops
this is an assignment i have to do for my class, basically the output should be something like this.. the characters depends on what the user inputs and how many rows the user wants to ouput.

This is my program so far-

#include<iomanip>
#include<fstream>
#include<cmath>
#include<iostream>

using namespace std;

int main()

{
	int num;
	char ch;
	int count, count2;
	
	

	cout<<"Enter the character you wish to use: "<<endl;
	cin>>ch;
	cout<<"Enter the number of rows: "<<endl;
	cin>>num;
	for(int row_A=0; row_A<num; row_A++)
		{
			cout<<ch<<'\n';
		
		}


}

it outputs this so far
*
*
*
*
*

i need it to output this
*
**
***
****
*****

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by jazzyangelz
0

Please use 'Code Tags' for posting code

to your qs. you will need one more loop, something like

for(int row_A=0; row_A<num; row_A++)
{
  for(int row_B=0;row_B<=row_A;row_B++)
  {
      cout << ch;
  }
  cout << "\n";
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.