944,093 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1080
  • C++ RSS
Sep 18th, 2007
0

simple question

Expand Post »
hey everyone, im new, and i have a simple question.

im writing this basic code for my class to input six different check amounts, then give the total and average. so far i have it so it works perfect with whole number. the only problem is, the numbers i need to use have decimals, and everytime i try and enter a value like 12.34, the whole things goes crazy. my code is a series of

C++ Syntax (Toggle Plain Text)
  1. cout << "Enter the amount of first check: " << endl;
  2. int check1;
  3. cin >> check1;

how can i fix this? thanks in advance

andrew
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hisdudeness300 is offline Offline
2 posts
since Sep 2007
Sep 18th, 2007
0

Re: simple question

Use "float" instaed of "int" O.K.
Reputation Points: 10
Solved Threads: 0
Light Poster
spankyg is offline Offline
38 posts
since Mar 2007
Sep 18th, 2007
0

Re: simple question

dude ur awesome. thanks. now looking back i see that it is the correct data type. thanks again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hisdudeness300 is offline Offline
2 posts
since Sep 2007
Sep 18th, 2007
0

Re: simple question

No problem! I'm still learning this crazy language myself. C+ is a brutal passion.
Glad I could help :-)
Reputation Points: 10
Solved Threads: 0
Light Poster
spankyg is offline Offline
38 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Problems with Switch
Next Thread in C++ Forum Timeline: char * to TByteDynArray in Borland C++ Builder 6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC