Documente Academic
Documente Profesional
Documente Cultură
cout<<"This program sums values entered" <<"by the user\n"; cout<<"Terminate the loop by entering" <<"a negative number\n"; //loop"forever" for(;;) { //fetch another number int value=0; cout<<"Enter next number:"; cin >>value; //if it's negative... if(value<0) { //...then exit break; } //...otherwise add the number to the
//accumulator accumulator=accumulator+value; } //now that we've exited the loop //output the accumulator result cout<<"\nThe total is" <<accumulator <<"\n";