A Program to Add Two Floating Numbers
In this example, we are giving a program to add two floating numbers which are given by the user.
Program to add two floating numbers:
#include <iostream>
using namespace std;
float main()
{
float first_number, second_number, sum;
cout << "Enter two floating point number: ";
// Two floating number entered by user stored
cin >> first_number >> second_number;
// Sum of the two numbers stored in the variable sum
sum = first_number + second_number;
// Displaying the value of sum
cout << first_number << "+" << second_number << "=" << sum;
return 0;
}
Output:
Enter two floating point number: 7.2 17.5 7.2 + 17.5 = 24.7