Double being rounded?

I'm using cpp.sh online to mess with some code, for some reason this is rounding to num to 3 instead of the actual value 3.4. Is this something I am doing wrong?

1
2
3
4
5
6
7
#include <iostream>

int main()
{
    double num = 68 / 20;
    std::cout << num; //num is 3?
}
Last edited on
1
2
// double num = 68 / 20; // integer division
double num = 68 / 20.0 ;
Thank you JLBorges!
Topic archived. No new replies allowed.