Object:-Write a Program in C to multiply 2 floating point number.
double firstNumber, secondNumber, product;
printf("Enter two numbers: ");
// Stores two floating point numbers in variable firstNumber and secondNumber respectively
scanf("%lf %lf", &firstNumber, &secondNumber);
// Performs multiplication and stores the result in variable productOfTwoNumbers
product = firstNumber * secondNumber;
// Result up to 2 decimal point is displayed using %.2lf
printf("Product = %.2lf", product);
Enter two numbers: 2.4
Product = 2.69
- In this program, user is asked to enter two numbers. These two numbers entered by the user is stored in variable firstNumber and secondNumber respectively. This is done using
- Then, the product of firstNumber and secondNumber is evaluated and the result is stored in variable productOfTwoNumbers.