More Chapter 5 practice problems!
Group,
I am new to programming so bear with me here. I am going through the ebook and am having a problem with a practice problem in chapter 5. I am almost getting the results that I want but the number is not correct. Please advise. (Please, if it is a simple noobie mistake, be kind.)
tsdad
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int input;
int input2;
cout << "Hey! Give me a number other than zero!" << "\n";
cin >> input;
if ( input != 0 )
{
while ( 1 )
{
cout << "Hey! Put in another number and I will add them up. But don't put in a zero or you will be called a Bonehead!" << "\n";
cin >> input2;
if ( input2 == 0 )
{
break;
}
int i;
i = i + input2;
cout << "The total of the numbers you gave me is " << i + input << " !" << "\n";
}
}
cout << "Hey, Bonehead! I said not to put in a 0. Go away!" << "\n";
}