In my college work, we submit our code to a platform that "corrects" the code automatically (inserts the entries in the code and compares the outputs generated with the template).
To get the entries, we always use the command cin
.
To exemplify my problem: Suppose I have the following entry:
1 1
2 3
5 8
0 0
And you have to output the sum of each pair of numbers, until both are 0, which identifies the end of the entries.
The code would be something like:
#include<iostream>
using namespace std;
int main(){
int x,y;
do{
cin >> x;
cin >> y;
if(x != 0 && y != 0){
z = x + y;
cout << z << endl;
}//fim if
}while(x != 0 && y != 0);//fim do.while
return 0;
}//fim main
Now, I need to solve the same problem, however, the end of the entries is demarcated by the end of the file (as opposed to having the input pair 0,0).
What condition do I have to put in place of while(x != 0 && y != 0);
to make this happen?