For two variables entered by the user, we must create separate functions for addition, subtraction, division, and multiplication.
Program Code:
#include <iostream>
using namespace std;
int addition(int ,int);
int subtraction(int, int);
int multiplication(int, int);
float division(int , int);
int modulus(int , int );
int addition(int num1, int num2)
{
int sum = num1 + num2;
return sum;
}
int subtraction(int num1, int num2)
{
return num1 - num2;
}
int multiplication(int num1, int num2)
{
return num1 * num2;
}
float division(int num1, int num2)
{
return num1 / num2;
}
int mod(int num1, int num2)
{
return num1 % num2;
}
int main()
{
int a, b;
cout<<("Enter the First Number = ");
cin>>a;
cout<<("Enter the Second Number = ");
cin>>b;
cout<<("Arithmetic Operations on Integer Values\n");
cout<<"Addition = "<<addition(a, b);
cout<<"subtraction = "<< subtraction(a, b);
cout<<"multiplication = "<< multiplication(a, b);
cout<<"division = "<<division(a, b);
cout<<"modulus = "<< mod(a, b);
}
Output:
Enter the First Number = 23
Enter the Second Number = 12
Arithmetic Operations on Integer Values
Addition = 35
subtraction = 11
multiplication = 276
division = 1
modulus = 11
Note: also read about Program to check Palindrome string
Follow Me
Please follow me to read my latest post on programming and technology if you like my post.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment