Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Find product of two floating point numbers in Python

How to write a C Program to multiply two floating point numbers

Posted on March 11, 2021March 11, 2021

Table of Contents

  • How to write a C Program to multiply two floating point numbers
    • Code to calculate product of two floats
      • Code to calculate product of two floating point numbers
      • Code to calculate product of two floating point numbers – using user input
      • Code to calculate product of two floating point numbers using function
      • Code to calculate product of two floating point numbers using function with user input

How to write a C Program to multiply two floating point numbers

In this article, we will discuss the concept of How to write a C Program to multiply two floating point numbers

In this post, we are going to learn how to write a program to calculate product of two floating point numbers using different methods in C programming language.

Code to calculate product of two floats

Code to calculate product of two floating point numbers

In this program, we will calculate product of two floating point numbers using variable declaration and initialization in C language

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("calculate Product of two floating point value\n");
   float first_No=12.5,last_No=5.5,product;
   //declaring and initializing variables

product=first_No * last_No;
//multiply given two numbers and assgn the result in variable product

printf("Product is : = %.3f",product);
//display result up to 3 decimal places
getch();
    return 0;
}

When the above code is executed, it produces the following result

calculate Product of two floating point value
Product is: = 68.750

 

 

Code to calculate product of two floating point numbers – using user input

In this program, we will calculate product of two floating point numbers using input from the user in C language

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("calculate Product of two floating point value\n");
   float first_No,last_No,product;
   //declaring three variables
    printf("Enter first number: ");
    //request input from the user
    scanf("%f",&first_No);
    //store the floating point value in variable first_No
    printf("Enter last number: ");
    //request input from the user
    scanf("%f",&last_No);
    //store the floating point value in variable last_No

product=first_No * last_No;
//multiply given two numbers and store the result in variable product

printf("Product is : = %.3f",product);
//display result up to 3 decimal places
getch();
    return 0;
}

When the above code is executed, it produces the following result

calculate Product of two floating point value
Enter first number: 10.6
Enter last number: 5.1
Product is: = 53.550

 

Code to calculate product of two floating point numbers using function

In this program, we will calculate product of two floating point numbers using function in C language

Program 3

#include <stdio.h>
#include <stdlib.h>
float mulNum(float,float);
int main()
{
    printf("find Product of floating point value\n");
   float f_No=50.5,s_No=25.6,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 two floating point value
Product is: = 1292.800

 

Code to calculate product of two floating point numbers using function with user input

In this program, we will calculate product of two floating point numbers using function with user input in C language

Program 4

#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 two floating point value
Enter first number: 10.6
Enter last number: 5.1
Product is: = 53.550

 

Suggested for you

Operator in C language

Function in C language

 

Similar post

Java code to product of two numbers

C code to product of two numbers

C++ code to product of two numbers

Python code to product of two numbers

 

Java code to Calculate product of two floating point numbers

C code to Calculate product of two floating point numbers

C++ code to Calculate product of two floating point numbers

Python code to Calculate product of two floating point numbers

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes