Make the result of integer division a float : Float « Data Type « C++






Make the result of integer division a float

Make the result of integer division a float
 



#include <iostream>
using namespace std;
int main(void)
{
   int firstOp = 10, secondOp = 4;
   float result = (float) firstOp / secondOp;
   cout << firstOp << " / " << secondOp << " = " << result;
   return 0;
}

           
         
  








Related examples in the same category

1.10.0 would be interpreted as floating point10.0 would be interpreted as floating point
2.Enter hexadecimal digits and a floating-point numberEnter hexadecimal digits and a floating-point number
3.cin to read float in C++cin to read float in C++
4.Float value pointer and int value pointerFloat value pointer and int value pointer
5.Demonstrates the definition and use of references.Demonstrates the definition and use of references.
6.Return float type from function
7.Get the square and cube of a float type number