What is the default type(int, float, char,....) of output of simple expression in "co

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdjunaid
    New Member
    • Oct 2013
    • 1

    What is the default type(int, float, char,....) of output of simple expression in "co

    i just type "cout<<10/3;" and the output is "3", my question is why this is not "3.333.." !!????
    is the default type is "integer"?? ???
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    10 is an integer. 3 is an integer. 10/3 is 3 because there are three 3's in 10.

    Integers have no decimal portion.

    Now if you do 10.0/3.0 then you have doubles and the result is 3.3333 as you expect.

    Comment

    Working...