You are missing the fact that 3 and 5 are integers, so you are getting integer division. To make the compiler perform floating point division, make one of them a real number:
double f = 3.0 / 5;
More Related Contents:
- Is multiplication and division using shift operators in C actually faster?
- Which is better option to use for dividing an integer number by 2?
- Fast multiplication/division by 2 for floats and doubles (C/C++)
- Fast division/mod by 10ˣ
- C++ Best way to get integer division and remainder
- Invalid operands to binary expression while implementing vector [closed]
- Why is GCC saying multiple definitions of main? I have one main [closed]
- Runtime error happens when deleting a node of the linklist [closed]
- How does the Comma Operator work
- return statement vs exit() in main()
- How to track down a “double free or corruption” error
- Downcasting using the ‘static_cast’ in C++
- Why does volatile exist?
- Using scanf() in C++ programs is faster than using cin?
- What are the advantages of using nullptr?
- std::vector, default construction, C++11 and breaking changes
- do {…} while(false)
- How can I add and subtract 128 bit integers in C or C++ if my compiler does not support them?
- Difference between try-catch syntax for function
- C++: Can a macro expand “abc” into ‘a’, ‘b’, ‘c’?
- Visual Studio 2010’s strange “warning LNK4042”
- “relocation R_X86_64_32S against ” linking Error
- Must the int main() function return a value in all compilers? [duplicate]
- SDL2: Fast Pixel Manipulation
- std::forward_list and std::forward_list::push_back
- What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?
- boost::asio with boost::unique_future
- Why can’t Visual Studio find my DLL? [duplicate]
- Is there a standard way of moving a range into a vector?
- Both asterisk and ampersand in a parameter