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!!
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: C++, question on double variable
  1. C question (Replies: 19)

  2. C++ question (Replies: 8)

  3. C question (Replies: 6)

  4. An easy c question (Replies: 7)