C Program to Multiply Two Floating-Point Numbers


This program will display the product value of two numbers entered by the user that are of ‘float’ data type, and then the product value will be printed on the screen.

To understand this example, you should know the following C programming concepts:

1. Variables, constants, and Literals in C

2. C data types

3. Programming operators in C

Go through the article named ‘Operators in C’ in the C language series to gain more information about this particular concept.



int main()


float a,b;

printf("Enter two values:\n");

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

float product=a*b; //Calculating the product value

printf("Product:%.2f",product); // .2 is used to round of the resultant value

return 0;





In the starting, the user is asked to enter two values which are stored in variables ‘a’ and ‘b’ respectively.

float product=a*b; then the product of both the variables is calculated and assigned to a variable named ‘product’ of ‘float’ data type.

Multiplying two ‘float’ values will always give a ‘float’ type value as a result.

printf(“Product: %.2f”,product); the result so obtained is printed on the screen with the use of ‘.2’ in between the format specifier to the round of the resultant value of ‘product’ variable up to 2 decimal places.



  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.