#include <iostream>
#include <sstream>
#include <stdlib.h>
using namespace std;
float numb; float sum= 0 ;
int main( )
{
cout << "This app calculates the sum of all entered numbers." << endl;
cout << "To stop the program, enter 0." << endl << endl;
cout << "Enter the first number: " ;
string input;
while ( cin >> input)
{
stringstream sst( input) ;
if ( sst>> numb) {
sum + = numb;
cout << "Sum equals: " << sum << endl << endl;
if ( numb== 0 )
{
cout << "Entered 0." << endl;
break ; // exits the while loop
}
cout << "Enter another number: " ;
}
else
{
cout << "Ignored entry " << input<< endl;
}
}
cout << "Press Enter to terminate the app." << endl;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0ZGxpYi5oPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmZsb2F0IG51bWI7IGZsb2F0IHN1bT0wOwoKaW50IG1haW4oKQp7CiAgICBjb3V0IDw8ICJUaGlzIGFwcCBjYWxjdWxhdGVzIHRoZSBzdW0gb2YgYWxsIGVudGVyZWQgbnVtYmVycy4iIDw8IGVuZGw7CiAgICBjb3V0IDw8ICJUbyBzdG9wIHRoZSBwcm9ncmFtLCBlbnRlciAwLiIgPDwgZW5kbCA8PCBlbmRsOwogICAgY291dCA8PCAiRW50ZXIgdGhlIGZpcnN0IG51bWJlcjogIjsKICAgIAogICAgc3RyaW5nIGlucHV0OyAgCiAKICAgIHdoaWxlKGNpbiA+PiBpbnB1dCkKICAgIHsKICAgIAlzdHJpbmdzdHJlYW0gc3N0KGlucHV0KTsgCiAgICAJaWYgKHNzdD4+bnVtYikgewoJICAgICAgICBzdW0gKz0gbnVtYjsKCiAgICAgICAgICAgIGNvdXQgPDwgIlN1bSBlcXVhbHM6ICIgPDwgc3VtIDw8IGVuZGwgPDwgZW5kbDsKCiAgICAgICAgCWlmIChudW1iPT0wKQogICAgICAgIAl7CiAgICAgICAgICAgIAljb3V0IDw8ICJFbnRlcmVkIDAuIiA8PCBlbmRsOwogICAgICAgICA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