how to terminate while loop and print values

This is an example from book:

Go through this drill step by step. Do not try to speed up by skipping steps. Test
each step by entering at least three pairs of values - more values would be better.

1. Write a program that consists of a while-loop that (each time around the
loop) reads in two ints and then prints them. Exit the program when a
terminating 'I' is entered.


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

using namespace std;

int main()
{
    int num1, num2;
    
    while(cin >> num1, num2){
              cout << num1, num2;
    }
    
    cin.ignore();
    cin.get();
    
    return 0;
}




When i try to terminate the loop with "I" or any other value instead of int, program just ends and those values that should be printed on the screen cout << num1, num2; do not appear. Why is that?
Topic archived. No new replies allowed.