Calculations

CPP program to multiply two numbers

CPP program to multiply two numbers

In this tutorial, we will discuss the CPP program to multiply two numbers.

In this topic, we will learn how to multiply two integer number in the C++ programming language

 

Multiply two integers

Program 1

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    cout << "Multiply two integer numbers" << endl;
    int numberOne, numberTwo,product;
     cout << "Enter the first number :";
     //Enter first integer number
     cin >> numberOne;
     //stored first integer number in variable numberOne
     cout << "Enter second number :";
     //Enter second integer number
     cin >> numberTwo;
     //stored second integer number in variable numberTwo
     product=numberOne * numberTwo;
     //performs multiplication and stored the result in the variable sumofnumbers

     cout<<"the product is: "<<product;
     getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Multiply  two integer numbers
Enter the first number: 12
Enter second number: 23
product is : 276

This is a simple C++ program to find the product of two integer numbers.

In the above program, we declared two different integer values such as  12 and 23 stored in variables numberOne, numberTwo respectively.
Then, we can find the product of given numbers using the * operator in c++

finally, we could display the result on the screen using the cout function in C++ language.

Multiply two floating point number

Program 2

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{

    cout << "Multiply two floating point numbers\n" <<endl;
    //description
    double numberOne, numberTwo,product;//variable declaration
     cout << "Enter first number :";
     //Enter first integer number
     cin >> numberOne;
     //stored first integer number in variable numberOne
     cout << "Enter second number :";
     //Enter second integer number
     cin >> numberTwo;
     //stored second integer number in variable numberTwo
     product=numberOne * numberTwo;
     //performs multiplication and stored the result in the variable sumofnumbers

     cout<<"the product is "<<product;
     getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Multiply two floating point numbers

Enter the first number: 2.45
Enter second number: 5.5
the product is 13.45

 

This is a simple C++ program to find the product of two floating point numbers.

In the above program, we declared two different floating point values such as  2.45 and 5.5 stored in variables numberOne, numberTwo respectively.
Then, we can find the product of given numbers using the * operator in c++

finally, we could display the result on the screen using the cout function in C++ language.

C program to multiply two numbers
Python program to multiply two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

1 month ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago