BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Program to Multiply two Floating Point Numbers

Last Updated: September 24, 2017 by Chaitanya Singh | Filed Under: C Programs

Program to multiply two floating point numbers and display the product as output.

Example 1: Program to display the product of two float numbers

In this program, user is asked to enter two float numbers and the program stores the entered values into the variable num1 and num2. The program then multiplies entered numbers and display the product as output.

#include <stdio.h>
int main(){
   float num1, num2, product;
   printf("Enter first Number: ");
   scanf("%f", &num1);
   printf("Enter second Number: ");
   scanf("%f", &num2);

   //Multiply num1 and num2
   product = num1 * num2;

   // Displaying result up to 3 decimal places. 
   printf("Product of entered numbers is:%.3f", product);
   return 0;
}

Output:

Enter first Number: 12.761
Enter second Number: 89.23
Product of entered numbers is:1138.664

Example 2: Program to multiply two numbers using function

In this program we are creating a user defined function product() that multiplies the numbers that we are passing to it during function call. This function returns the product of these numbers. To understand this program you should have the knowledge of following C Programming concepts:

  1. C – Functions
  2. C – Function call by Value
#include <stdio.h>
/* Creating a user defined function product that
 * multiplies the numbers that are passed as an argument
 * to this function. It returns the product of these numbers
 */
float product(float a, float b){
    return a*b;
}
int main()
{
    float num1, num2, prod;
    printf("Enter first Number: ");
    scanf("%f", &num1);
    printf("Enter second Number: ");
    scanf("%f", &num2);

    // Calling product function
    prod  = product(num1, num2);

    // Displaying result up to 3 decimal places.
    printf("Product of entered numbers is:%.3f", prod);

    return 0;
}

Output:

Enter first Number: 12.761
Enter second Number: 89.23
Product of entered numbers is:1138.664

Check out these related C Programs:

  1. C Program to Add two numbers
  2. C Program to print an integer entered by user
  3. Hello World Program in C
  4. C Program to find Palindrome numbers in a given range
  5. C Program to convert lowercase string to uppercase

Top Related Articles:

  1. C Program to find the Size of int, float, double and char
  2. C Program to calculate Area of an Equilateral triangle
  3. C Program to Add two distances using structure
  4. Hello World Program in C
  5. C Program to Generate Multiplication Table

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap