Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
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
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on a Homework extra credit. Direth Visual Basic 2 Dec 5th, 2007 3:20 PM
linked list keep getting extra node kruptof C++ 10 Dec 22nd, 2006 11:44 PM
Error handling inputs Konnor Java 4 Mar 11th, 2006 11:43 PM
struct program skipping inputs codylee270 C 7 Dec 5th, 2005 8:02 AM
A standards question, optional inputs into Methods Arla C# 4 Apr 27th, 2005 11:38 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC