Help with double

Hello,

I'm trying to do a exercise from a book im learning from but getting stuck with the syntax.

the question goes as follows

'Read the age into double to allow for the person to be five-and-a-half years old rather just five"

if my

int age =-1;

how do i read that into a double?

thanks.
Show me how you read into an int and then explain to me why you cannot read the double the same way, please.
int age;
cin>>age;

the compiler will show error if i use double age; as a statement because its already been defined by int and you cannot have 2 variables with the same name.

...then do away the int age?
thanks for the help i was under the impression that i needed to have a int then some how read that int into a double which was giving me a headache but i see now its as simple as

{
cout<<"Please enter your first name and age\n";
string first;
double age;
cin>>first>>age;
cout<<"Hello ,"<<first<<' '<<age<<'\n';
keep_window_open();
}

again thanks.
Topic archived. No new replies allowed.