cin to read float in C++ : Float « Data Type « C++






cin to read float in C++

cin to read float in C++
 

#include <iostream>
using namespace std;
int main()
{
   double x, y;
   cout << "Enter two floating-point values: ";
   cin >> x ;
   cin >> y;
   cout << "The average of the two numbers is: " << (x + y)/2.0 << endl;
   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.Make the result of integer division a floatMake the result of integer division a float
3.Enter hexadecimal digits and a floating-point numberEnter hexadecimal digits and a floating-point number
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