Friday, May 30, 2008

Week 6 Problem 1

Problem 1 (Exercise R4.9)

Explain the differences between 2, 2.0, ‘2’, “2”, and “2.0”.

2 comments:

Anonymous said...

OK, I don't know if it's me, but do these questions seem to ask for answers that are somehow not defined in this book? Nothing seems relative to me, but that's probably another topic.

I have 2 - as an INT; 2.0 as a Float, '2' - I can't seem to find; "2" is a String Int; and "2.0" as a String Float. I'm sure I'm wrong, so if anyone can provide direction on where to find this at I would be eternally grateful. Especially for the '2'.

I'm better with more complex questions for some reason LOL

Thanks

Pep

Cao06 said...

'2' is a character literal and will only accept characters within the ' '. This will also produce an output of 2.

Hope that helps,
Tuyen