I am using cin as condition for while loop where it accepts an integer unless an end of file or a character is entered. But the console window disappears just after the result. How can I hold the screen
#include<iostream>
using namespace std;
int main() {
int num = 0, sum = 0;
while (cin >> num) {
sum += num;
}
cout << "Sum is: "
<< sum
<< endl;
cout << endl;
cin.get();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire