C Program to Multiply two Floating Point Numbers

59
views
Floating Point Numbers
(Last Updated On: September 2, 2018)

In this program, you’ll learn to Multiply two Floating Point Numbers.

The product of these 2 Floating Point Numbers which are “a” and “b” is stored in a variable and displayed on the screen.

To understand this example of Floating Point Numbers, you should have the knowledge of following C programming topics:

  • Data Types
  • Constants
  • Variables
  • Input Output
  • Operator

Program to Multiply Two Numbers

#include <stdio.h>
int main()
{
double a, b, productOfNumbers;
printf("Enter the numbers: ");

scanf("%lf %lf", &a, &b);

productOfNumbers = a * b;

printf("Product = %.2lf", productofNumbers);
return 0;
}

Output

Enter the numbers: 2.4
1.12
Product = 2.69

Multiply two Floating Point Numbers

In the above program, the user has been asked to enter two numbers.

The two numbers given by the user is stored in variable a and b respectively. This is done using the scanf()function.

[irp]

Then, the product of a and b is evaluated and the result is stored in the variable productOfNumbers.

Finally, the productOfNumbers is displayed on the screen using printf() function.

Notice that, the result is round to second decimal place using %.2lf conversion character.

Related C Programs

Ask your questions and clarify your/others doubts on Find ASCII Value in C by commenting. Documentation