PracticeDev/study_cpp/cpp_primer_source_code/Chapter 17/check_it.cpp

27 lines
479 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
// check_it.cpp -- checking for valid input
#include <iostream>
int main()
{
using namespace std;
cout << "Enter numbers: ";
int sum = 0;
int input;
while (cin >> input)
{
sum += input;
}
cout << "Last value entered = " << input << endl;
cout << "Sum = " << sum << endl;
/* keeping output window open */
/*
cin.clear();
while (cin.get() != '\n')
continue;
cin.get();
*/
return 0;
}