Mega Code Archive

 
Categories / C++ / Data Type
 

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; }