Question: I want to output this result at screen :  

> 
> 1  
>  23  
>  456  
>  78910  
> 
> 
> 
> 

how to do that??  

I tried to write this code:

```
for (int line = 1; line <= 4; line++){
    int num = line;
    int i = 1;
    for (int x = 1; x <= line; x++){
        cout << num;
        num = num + i;
    }
    cout << endl;
}

```

but the output is :

> 
> 1  
> 23  
> 345  
> 4567
> 
> 
> 

please help !!!

Answer: 
Create `num` outside the `for` loop and increment it after you write it out.

```
int num = 1;
for (int line = 1; line <= 4; line++){
    for (int x = 1; x <= line; x++){
        cout << num;
        ++num;
    }
    cout << endl;
}

```
```
int num = 1;
int i = 1;
for (int line = 1; line <= 4; line++){
    for (int x = 1; x <= line; x++){
        cout << num;
        num = num + i;
    }
    cout << endl;
}

```