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

C++ Program to multiply two floating point numbers

Posted on March 11, 2021March 11, 2021

Table of Contents

  • 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 – 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

C++ Program to multiply two floating point numbers

In this article, we will discuss the concept of 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++ program.

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 <iostream>
#include <conio.h>
using namespace std;

int main()
{
    cout<<"calculate Product of two floating point numbers\n";
   float first_No=10.25,last_No=5.5,product;
   //declaring and initializing variables

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

cout<<"Product is : "<<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 numbers
Product is :  56.375

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

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

Program 2

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    cout<<"calculate Product of two floating point value\n";
   float first_No,last_No,product;
   //declaring three variables
    cout<<"Enter first number: ";
    //request input from the user
    cin>>first_No;
    //store the floating point value in variable first_No
    cout<<"Enter last number: ";
    //request input from the user
    cin>>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

cout<<"Product is : "<<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 numbers
Enter first number: 15.25
Enter lastt number: 25.75
Product is :  392.688

 

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 <iostream>
#include <conio.h>
using namespace std;

float mulNum(float,float);
//function prototype
int main()
{
    cout<<"find Product of floating point value\n";
   float f_No=40.4,s_No=20.6,product;
   //declaring and initializing variables
    product=mulNum(f_No,s_No);
    //calling the function and assigning the output to product variable
    cout<<"Product is : = "<<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

calculate Product of two floating point numbers
Product is :  832.24

 

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 <iostream>
#include <conio.h>
using namespace std;
float mulNum(float,float);
int main()
{
    cout<<"find Product of floating point value\n";
   float f_No,s_No,product;
    cout<<"Enter first number: ";
    //ask input from the user
    cin>>f_No;
    //storing the input value in variable f_No
     cout<<"Enter second number: ";
    //ask input from the user
    cin>>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
    cout<<"Product is : = "<<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

calculate Product of two floating point numbers
Enter first number: 10.10
Enter last number: 20.20
Product is : 204.02

 

Suggested post

operator 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