Answers for "float division in c++"

C++
3

c++ integer division

// truncates decimal
cout << 20.0 / 3; // 6.66667 
cout <<   20 / 3; // 6
cout <<  -20 / 3; // -6
Posted by: Guest on December-13-2020
1

cpp get float from integer division

float ans = (float)a / (float)b;
Posted by: Guest on April-01-2021

Browse Popular Code Answers by Language