Guest_imported
New member
- Jan 1, 1970
- 0
help. i'm taking a c++ course, and i need to do something very simple. i need to write a program that uses nested loops to output this:
1
1 2
1 2 3
1 2 3 4
what i come up w/ is this:
1
2
3
4
so i know i'm using counters properly. but how do i repeat previous results on each line? i would so appreciate any help!
here's what i have so far:
#include <iostream>
int main()
{
int counter;
counter = 1; // Starting position
int nextNumber;
while( counter <= 4 ) // Condition
{
cout << counter << endl;
counter = counter + 1; // Increment variable
}
}
jenny
1
1 2
1 2 3
1 2 3 4
what i come up w/ is this:
1
2
3
4
so i know i'm using counters properly. but how do i repeat previous results on each line? i would so appreciate any help!
here's what i have so far:
#include <iostream>
int main()
{
int counter;
counter = 1; // Starting position
int nextNumber;
while( counter <= 4 ) // Condition
{
cout << counter << endl;
counter = counter + 1; // Increment variable
}
}
jenny