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 <stdio.h>
float main()
{
float first_number, second_number, sum;
printf("Enter two floating point number: ");
// Two floating number entered by user stored
scanf("%lf %lf", &first_number, &second_number);
// Sum of the two numbers stored in the variable sum
sum = first_number + second_number;
// Displaying the value of sum
printf("%lf + %lf = %.2lf", first_number, second_number, sum);
return 0;
}
Output:
Enter two floating point number: 7.2 17.5 7.2 + 17.5 = 24.7