Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
What is the default type(int, float, char,....) of output of simple expression in "co
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
jdjunaid
New Member
Join Date:
Oct 2013
Posts:
1
#1
What is the default type(int, float, char,....) of output of simple expression in "co
Oct 21 '13, 02:37 PM
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
Join Date:
Mar 2007
Posts:
9214
#2
Oct 21 '13, 03:33 PM
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
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment