View Single Post
Old Apr 1st, 2008, 8:03 PM   #1
wannabe7
Newbie
 
Join Date: Dec 2007
Posts: 16
Rep Power: 0 wannabe7 is on a distinguished road
Computations: extra inputs?

My program:
#include <iostream>
using namespace std;
int main()
{
    //I'm declaring some variables.
    int number1, number2, product, sum;
    cout << "Please enter an integar (whole number): \n";
    cin >> number1;
    cout << "Please enter a another integar: \n";
    cin >> number2;
    //Computing the numbers.
    product = number1 * number2;
    sum = number1 + number2;   
    //This will reveal the final computations.
    cout << "The sum of " << number1 << " and " << number2 << " equals: " << sum << "\n";
    cout << "The product of " << number1 << " and " << number2 << " equals: " << product << "\n";
    cin >> sum >> product;
    cin.ignore();
    return 0;
}

The problem with this code is that after the program finishes everything that it needs to, it won't terminate. Instead, it forces me to input two extras times. I suspect that it's probably because of the code
cin >> sum >> product;
. The problem is, when/if I remove that code, the program won't execute. I've tried everything I knew but can't a way around it. Maybe something else is wrong with the program?
Thanks in advance.
__________________
Aspiring Game Designer
wannabe7 is offline   Reply With Quote