Page MenuHomec4science

exercise02-3.cpp
No OneTemporary

File Metadata

Created
Mon, Jul 7, 08:52

exercise02-3.cpp

/*
* exercise-template.cpp <--- The name of the source file goes here
*
* <--- Description of the program goes here.
*
* Created on: September 02, 2015 <--- Fill in the date here
* Author: Davide Forti <davide.forti@epfl.ch> <--- Fill in your name (and e-mail) here
*/
/*
* Any headers you need to include should be specified on the next lines
*/
#include <iostream>
int main(int argc, char* argv[])
{
int entry;
int sum, stop;
std::cout << " Enter all the numbers you want to sum : \n";
while (stop == 0)
{
std::cin >> entry;
if(entry != -1)
{
sum += entry;
}
else
{
stop = 1;
}
}
std::cout << "The sum of all the number you entered is :" << sum << ". \n";
return 0;
}

Event Timeline