C Program to Multiply two Floating Point Numbers

In this tutorial you will learn about the C Program to Multiply two Floating Point Numbers and its application with practical example.

In this tutorial, we will learn to create a program to multiply two floating point numbers using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • C Variables
  • C Data Types
  • C Input Output
  • C Operators
  • C Function

Program to Multiply two Floating Point Numbers

In this program we will multiply two floating point numbers entered by user. We would first declared and initialized the required variables. Next, we would prompt user to input two floating point numbers. Later in the program we will multiply the numbers entered by user. We will then display the result to user.

Output:-

C-Program-to-Multiply-two-Floating-Point-Numbers

In the above program, we have first declared and initialized a set variables required in the program.

  • n1 = it holds the first float number
  • n2 = it holds the second float number
  • product = it holds the product of n1 and n2

In the next statement user will be prompted to enter the two floating point number values which will be assigned to variable ‘n1’ and ‘n2’ respectively. Next, we will perform multiplication of both float numbers numbers (n1 and n2) and assign result to product. Now, we will be displaying the multiplication result of two floating point numbers using printf statement.

Program to multiply two numbers using function

In this program we will multiply two floating point numbers entered by user. We would first declared and initialized the required variables. Next, we would prompt user to input two floating point numbers. Later in the program we will multiply using a user defined function and display the product of the float numbers.

Output:-

C-Program-to-Multiply-two-Floating-Point-Numbers-using-function

In the above program, We have defined a user defined function called multiply(), which means to accept two float numbers and return product of the numbers passed as parameters.

Next, we have declared and initialized a set variables required in the program.

  • n1 = it holds the first float number
  • n2 = it holds the second float number
  • product = it holds the product of n1 and n2

In the next statement user will be prompted to enter the two floating point values which will be assigned to variable ‘n1’ and ‘n2’ respectively. Next, we have called multiply function and assigned its return value to ‘product’. Now, we will be displaying the product of two float numbers using printf statement.

In this tutorial we have learn about the C Program to Multiply two Floating Point Numbers and its application with practical example. I hope you will like this tutorial.