Easy Tutorial
❮ C Function Printf C Exercise Example14 ❯

C Language Example - Multiplying Two Floating-Point Numbers

C Language Examples

Enter two floating-point numbers and calculate their product.

Example

#include <stdio.h>
int main()
{
    double firstNumber, secondNumber, product;
    printf("Enter two floating-point numbers: ");

    // User inputs two floating-point numbers
    scanf("%lf %lf", &firstNumber, &secondNumber);  

    // Multiplying the two floating-point numbers
    product = firstNumber * secondNumber;  

    // Output the result, %.2lf retains two decimal points
    printf("Result = %.2lf", product);

    return 0;
}

Running Result:

Enter two floating-point numbers: 1.2 2.345
Result = 2.81

C Language Examples

❮ C Function Printf C Exercise Example14 ❯