0

make and run a program that will display the output below

#####
####
###
##
#

it should use forloops,, i cant make one, but the code is long.

i cant make it work

also, you need to use the concept of rows and columns

heres mine,, its epic fail
pls help me

#include<iostream>

using namespace std;

int main()
{
	int row;

	for(row=1; row<=5; row++)
	{cout<<"#";
	cout<<'/n';
	for(row=1; row<=4; row++)
	cout<<"#";
	cout<<'/n';
	for(row=1; row<=3; row++)
	cout<<"#";
	cout<<'/n';
	for(row=1; row<=2; row++)
	cout<<"#";
	cout<<'/n';
	for(row=1; row<=1; row++)
	cout<<"#";
	cout<<'/n';
	}
	system("pause");
	return 0;
}
5
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by erikandr
0

You will need nested for loops:

for(over each of the rows)
{  
   for(over each of the columns)
   {

Find a relationship between the columns and the rows. Take another crack at it, and post back with your updated code.

0

yeah i don't know...i just learned loops last week..and i bombed my assignment..got a big fat zero..so good luck!

0

If you want to loop over something, the syntax is as following:

int rowVector[5]; // Initializing

for (int i = 0; i < 5; i++)
{
 rowVector[i] = i;
 cout << rowVector[i]; 
}

Initializing an array with both rows and columns is done as following:

arrar[number_of_rows][number_of_columns]

Hope I didn't give you too much help there.

Cheers,
Erik

Edited by erikandr: n/a

This topic has been dead for over six months. 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.