Hi

I've been trying to write a program to generate the sequence:
1
12
123
1234
12345
...

It is the user who decides how many terms of the sequence are displayed. For example, the terms given above are five. Could you please help me with it? I think I need to use the for loop here. Given below are some random steps I put down while trying! Please help me.

Code:
#include <iostream>
#include <cstdlib>

using namespace std;

int main()

{
     
     int i, prevterm = 1, nexterm;
     
     for ( i=0; i<=n; i++)
     
     {
     
     nexterm
     
     cout << prevterm << prevterm
     
     nexterm = ++prevterm
     
     nth term  = 10^(n-1)(n-1) + n
     2 + (2-1) = 21
     3 + 2 = 23
     
     1
     12
     123
     1234
     12345