Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C++, question on double variable

  1. Mar 26, 2005 #1
    I want to know if i use double variable and the input value is an integer, will that variable be stored as a decimal? How about for float variable?

    ex. double x, and cin 3 for x, will x be stored as 3 or 3.0?

  2. jcsd
  3. Mar 26, 2005 #2
    C++ will used the declared variable type when assigning values to said variable. So, if you had int x and you tried to store 3.14159 x would end up holding 3; likewise, float x would store all values as floats.
  4. Mar 26, 2005 #3
    thanks a lot!!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook