0

This is my code below:

using namespace std;

int main(int argc, char *argv[])
{
    int thisisanumber;
    int SecondNumber;
    int TotalNumber;
    TotalNumber = thisisanumber + SecondNumber;
     
  cout<<"Please enter a number: ";
  cin>> thisisanumber;
  cin.ignore();
  cout<<"You entered: "<< thisisanumber <<"\n";
  cin.get();
  
  cout<<"Please enter a second number: ";
  cin>> SecondNumber;
  cin.ignore();
  cout<<"Your second number is: "<< SecondNumber <<"\n";
  cin.get();
  
  cout<<"Your Total is: "<< TotalNumber <<"\n";
  cin.get();
  
  cout<<"Thank you for your patience with my new small but mighty program!";
  cin.ignore(); 
  
  
}

I'm starting out...obviously, a newbie here. However, I cannot understand that when I run this code with the first number being 34 and my second number being 40 ....I get the output of 39.

This is not my homework. I'm just trying to learn on my own for now.

Thanks for all you help.

Sincerely,
St!tch.

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

And I can't understand how 99% of new posters can fail to read the intro threads properly (or at all).
http://www.daniweb.com/forums/announcement8-3.html

Or completely ignore the watermark at the back of the edit window.

Or fail to press "preview" to make sure their post is going to come out right.

Or fail to read other peoples posts and wonder, "hey, I wonder how they got the code all nice?".

0

I'm starting out...obviously, a newbie here. However, I cannot understand that when I run this code with the first number being 34 and my second number being 40 ....I get the output of 39.

This is not my homework. I'm just trying to learn on my own for now.

Thanks for all you help.

Sincerely,
St!tch.

Move line 8 down to line 21. Code is executed in the order that it appears in the program, which means the two numbers can not be added together until after their values are known.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.