. .
:
cout << (5 / 2) << endl;
cout << (5. / 2) << endl;
cout << (5.0 / 2) << endl;
:
2
2.5
2.5
You can see that the first line uses integer division (because both values are integers), while 5.and 5.0are both identified as types of floating-point, and so they call "normal division."
source
share