Multiplication program of two floating-point numbers using function in C
- Home
- Calculations
- Multiplication program of two floating-point numbers using function in C
- On
- By
- 0 Comment
- Categories: Calculations, multiply
Multiplication program of two floating-point numbers using function in C
Multiplication program of two floating-point numbers using function in C
In this tutorial, we will discuss the concept of Multiplication program of two floating-point numbers using function in C
In this topic, we are going to learn how to multiply two floating-point numbers using the function in C language
What is multiplication
The multiplication is a method of combining a group of equal size. The multiplication is an arithmetic operation inverse of division
It is one of the four basic operation of arithmetic calculation others being addition,subtraction,division
The multiplication of two numbers means, it is the operation one number is combining within another using multiply(*) operator.
The answer of a multiplication operation is called as “product”
Program to multiply of two floating-point numbers in C
Program to find product of two numbers
The program calculates the product of the given floating point numbers using function in C language
Program 1
#include <stdio.h> #include <stdlib.h> float mulNum(float,float); int main() { printf("find Product of floating point value\n"); float f_No=10.5,s_No=15.9,product; //declaring and initializing variables product=mulNum(f_No,s_No); //calling the function and assigning the output to product variable printf("Product is : = %.3f",product); //display result up to 3 decimal places getch(); return 0; } float mulNum(float a, float b){//function definition float result=a * b; //multiply two numbers and store the output in variable result return result; //return the result to main method }
When the above code is executed, it produces the following result
find Product of floating point value Product is : =166.950
Program to find product of two numbers- Takes input from the user
The program allows the user to enter two floating-point numbers and then it calculates the multiplication of the given numbers using function in C language
Program 2
#include <stdio.h> #include <stdlib.h> float mulNum(float,float); int main() { printf("find Product of floating point value\n"); float f_No,s_No,product; printf("Enter first number: "); //ask input from the user scanf("%f",&f_No); //storing the input value in variable f_No printf("Enter second number: "); //ask input from the user scanf("%f",&s_No); //storing the input value in variable s_No product=mulNum(f_No,s_No); //calling the function and assigning the output to product variable printf("Product is : = %.3f",product); //display result up to 3 decimal places getch(); return 0; } float mulNum(float a, float b){//function definition float result=a * b; //multiply two numbers and store the output in variable result return result; //return the result to main method }
When the above code is executed, it produces the following result
find Product of floating point value Enter first number: 23.23 Enter second number: 12.12 Product is : =281.548
Suggested for you
Similar post
Find product of two numbers using function in C language
Find product of two numbers using recursion in C language
Find product of two numbers using pointer in C language
Multiply two numbers in C++ language
Multiply two numbers in Python language
Multiply two numbers in Java language
Multiply of two floating-point numbers in Java
Multiply of two floating-point numbers in C
Multiply of two floating-point numbers in C++
Multiply of two floating-point numbers in Python