IMHO it is worth looking at formatting a string and using that only for
output. Think of the functionality of sprintf().
"Andrew Heath" <andrew.heath@studentmail.newcastle.edu.au> wrote in message
news:3F8F5158.9000909@studentmail.newcastle.edu.au...
nadz wrote:
I don't think of myself has a expert programmer and am a student just
like
you only maybe a little farther along. But my recommendation would be
to
work it out into two seperate variables one containing the whole number
and
the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I
hope
that helps.
~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...
this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.
This is what I am supposed to do:
Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45
23
45
This is what I have so far:
#include <iostream>
#include <string>
using namespace std;
int main(){
float a = 0;
double b = 0;
cout<<"Enter a 4 digit number example 23.45: "<< endl;
cin>>a>>b;
cout<<a<<"\n."<<b<< endl;
return 0;
}
again, I don't want the answer but I am missing something.
Thanks so much!!!
--
Posted via http://dbforums.com
Another suggestion - the program requirements you have given do not
explicitly state "you must use a float or double variable". So all you
might have to deal with is two integers seperated by a '.' or even two
strings.
.