## C++ programs to multiply and divide two numbers

C++ program to multiply and divide two numbers operation is almost same as adding or subtracting two numbers. However you can see the guide to multiply and divide using C language also. In this program we will take to numbers from the user and then multiply and divide them.

## Program to multiply and divide two numbers

See the simple program where we have taken input and printed  output after performing multiplication and division operations. We can also print the reminder after division using the same concept.

``````// c++ program to multiply and divide two numbers

#include <iostream>
using namespace std;

int main(){
int firstNum, secondNum, multiply, divide, reminder;

cout << "Enter the first number here : ";
cin >> firstNum;
cout << "Enter the second number here : ";
cin >> secondNum;

multiply = firstNum * secondNum;
divide = firstNum / secondNum;
reminder = firstNum % secondNum;

cout <<"\nResult after multiply is = " << multiply << endl;
cout <<"Result after division is = " << divide << endl;
cout <<"Reminder is = " << reminder << endl;

return 0;
}``````

### Output of multiply and divide program Obviously we can use float or double data type to avoid the reminder after division. Then the result will be fraction number. Try this in your own to multiply and divide two fraction numbers.

## Multiply and divide using class in C++

In this program we will multiply and divide two number using a class. At first we will take input from the user and then multiply them and divide first number by second and print the output.

``````// c++ program to multiply and divide two numbers using a class

#include <iostream>
using namespace std;

class class_to_mul{    // creating a class to multiply and divide
int first, second;

public:
void taking_input(){
cout << "Enter two integers here to add them : \n";
cin >> first >> second;
}

void funct_to_multiply(){
cout << "\nResult after multiply is = " << first * second << endl;
cout << "Result after division is = " << first / second << endl;
}

};

int main(){
class_to_mul a; // Creating an object

a.taking_input();
a.funct_to_multiply();

return 0;
}``````

### Output of this multiply and divide program:

``````Enter two integers here to add them :
100 5

Result after multiply is = 500
Result after division is = 20``````

Previous pageAdd two numbers

Next pageAdd two complex number