| | |
Code not adding my numbers correctly...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Solved Threads: 0
This is my code below:
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.
C++ Syntax (Toggle Plain Text)
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(); }
This is not my homework. I'm just trying to learn on my own for now.
Thanks for all you help.
Sincerely,
St!tch.
Last edited by Ancient Dragon; Sep 12th, 2007 at 3:32 am. Reason: add code tags
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?".
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?".
•
•
•
•
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Adding numbers (Python)
- adding numbers in tk (Python)
- Code line numbers - causing paste problems (DaniWeb Community Feedback)
- C Program for Adding two numbers without using + sign (C)
- Finding Perfect Numbers. "help plz" (C++)
- error while adding two numbers (C#)
- How many different numbers are there? (C++)
- Command line calculator (C)
- what does this code do? (PHP)
Other Threads in the C++ Forum
- Previous Thread: Variable scope problem
- Next Thread: lnk2019 error
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






