Skip to content

Instantly share code, notes, and snippets.

@slyphon
Last active August 29, 2015 14:22
Show Gist options
  • Save slyphon/813b37dd360ee2e5e860 to your computer and use it in GitHub Desktop.
Save slyphon/813b37dd360ee2e5e860 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
float sum = 0;
int i;
for (i = 0; i < 5; i++)
{
int t = 0;
cout << "Please enter in number " << i + 1 << endl;
cin >> t;
sum = sum + t;
}
if ((sum + 0.5) >= (int (sum + 1)))
{
sum = sum + 1;
sum = static_cast<int>(sum);
cout << "The sum rounds to " << sum << endl;
}
else
{
sum = static_cast<int>(sum);
cout << "The sum rounds to " << sum << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment