Write C programming example demonstrate the product of two floating type numbers. The product of floating type numbers is achieved using the arithmetic * operator, similar to integer type variables.

C program to multiply two floating point numbers - Source code

#include <stdio.h>
int main(){
float number1, number2, product;
printf("Enter first Number: ");
scanf("%f", &number1);
printf("Enter second Number: ");
scanf("%f", &number2);
//Multiply number1 and number2
product = number1 * number2;
// Displaying result up to 3 decimal places.
printf("Product of entered numbers is:%.3f", product);
return 0;
}

Program Output

Case 1:
Enter first Number: 937.65
Enter second Number: 137.98
Product of entered numbers is:129376.945
Case 2:
Enter first Number: 48.89
Enter second Number: 37.81
Product of entered numbers is:1848.531

Program Explanation

1. In this program, user is asked to enter two numbers one by one. These two numbers entered by the user are stored in the floating type variables number1 and number2. This is done using scanf() function.

2. Then, the product of number1 and number2 is evaluated and the result is stored in another floating type variable product.

3. Finally, the value of variable product is displayed on the screen using printf() function.

4. Here note that %.3f is used instead of regular %f format specifier. This is to limit the product result up to three decimal places.

C program to multiply two floating point numbers - Source codeProgram OutputProgram Explanation1. In this program, user is asked to enter two numbers one by one. These two numbers entered by the user are stored in the floating type variables number1 and number2. This is done using scanf() function.

2. Then, the product of number1 and number2 is evaluated and the result is stored in another floating type variable product.

3. Finally, the value of variable product is displayed on the screen using printf() function.

4. Here note that %.3f is used instead of regular %f format specifier. This is to limit the product result up to three decimal places.

need an explanation for this answer? contact us directly to get an explanation for this answer