simple question

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 2
Reputation: hisdudeness300 is an unknown quantity at this point 
Solved Threads: 0
hisdudeness300 hisdudeness300 is offline Offline
Newbie Poster

simple question

 
0
  #1
Sep 18th, 2007
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

  1. cout << "Enter the amount of first check: " << endl;
  2. int check1;
  3. cin >> check1;

how can i fix this? thanks in advance

andrew
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 38
Reputation: spankyg is an unknown quantity at this point 
Solved Threads: 0
spankyg's Avatar
spankyg spankyg is offline Offline
Light Poster

Re: simple question

 
0
  #2
Sep 18th, 2007
Use "float" instaed of "int" O.K.
Education is what remains after one has forgotten what one has learned in school.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 2
Reputation: hisdudeness300 is an unknown quantity at this point 
Solved Threads: 0
hisdudeness300 hisdudeness300 is offline Offline
Newbie Poster

Re: simple question

 
0
  #3
Sep 18th, 2007
dude ur awesome. thanks. now looking back i see that it is the correct data type. thanks again
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 38
Reputation: spankyg is an unknown quantity at this point 
Solved Threads: 0
spankyg's Avatar
spankyg spankyg is offline Offline
Light Poster

Re: simple question

 
0
  #4
Sep 18th, 2007
No problem! I'm still learning this crazy language myself. C+ is a brutal passion.
Glad I could help :-)
Education is what remains after one has forgotten what one has learned in school.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC