How to get a specific output from input.

I am trying to write code to this problem. I am not sure what to do. This is the furthest I have gotten.

I want the input to be
Input:
2
6
4
0
-1

Output:
2
6
4
0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int value = 0;
    
    do 
    {
    cin >> value;
    }
    while ( value >= 0);
    
    return 0;
}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int value = 0;
    
    while(cin >> value) 
    {
        if(value >= 0) cout << value << endl;
    }    
    return 0;
}
Topic archived. No new replies allowed.