- #1
PainterGuy
- 940
- 69
Hello everyone,
I was working to create a program to list the sequence:
1
12
123
1234
12345
...
The user will decides how many terms of sequence are displayed. For example the terms, n, given above are five. Will you help me please? I think I need to use the FOR loop here. Given below are some random steps I put down. My math is weak.
second term - first term = 11
third term - second term = 111
fourth term - third term = 1111
...
The code written below is wrong. I have included it so that you can help.
Cheers
I was working to create a program to list the sequence:
1
12
123
1234
12345
...
The user will decides how many terms of sequence are displayed. For example the terms, n, given above are five. Will you help me please? I think I need to use the FOR loop here. Given below are some random steps I put down. My math is weak.
second term - first term = 11
third term - second term = 111
fourth term - third term = 1111
...
The code written below is wrong. I have included it so that you can help.
Code:
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
int n, i;
cout << "How many terms are required?: ";
cin >> n;
cout << " " << endl;
for ( i=1; i<=n; i =i+(pow(10,i)))
{
cout << i << endl;
}
}
Cheers