Connecting Tech Pros Worldwide Forums | Help | Site Map

decimals

westjon64@hotmail.com
Guest
 
Posts: n/a
#1: Oct 12 '05
i am fairly new to c++, i need to know how to make it so you can input
decimals into a file using the cin >> a command instead of just being
able to input whole numbers and also how to make it so that it outputs
decimals and not just rounded off whole numbers


Artie Gold
Guest
 
Posts: n/a
#2: Oct 12 '05

re: decimals


westjon64@hotmail.com wrote:[color=blue]
> i am fairly new to c++, i need to know how to make it so you can input
> decimals into a file using the cin >> a command instead of just being
> able to input whole numbers and also how to make it so that it outputs
> decimals and not just rounded off whole numbers
>[/color]
What have you tried? (Show us some brief *real* code.)

Have you looked at a book? (See http://www.accu.org for suggestions.)

This ain't rocket surgery...

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
John Harrison
Guest
 
Posts: n/a
#3: Oct 12 '05

re: decimals


westjon64@hotmail.com wrote:[color=blue]
> i am fairly new to c++, i need to know how to make it so you can input
> decimals into a file using the cin >> a command instead of just being
> able to input whole numbers and also how to make it so that it outputs
> decimals and not just rounded off whole numbers
>[/color]

You need to decalre you variables as float or double.

double x;
cin >> x;
cout << x;

BTW they are called floating point numbers, not decimals.

john
Closed Thread