Create A C++ Function That Computes The Sum, Diff, Prod, Quotient, and Modulus

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Create a C++ function that will compute the sum, difference, product, quotient, and modulus of

two inputted integer numbers


OUTPUT:

*This is only an example, you can input any number for a and b

INPUT:
#include <iostream>

using namespace std;


int addition (int a, int b)

int r = a + b;

return r;

int subtraction (int a, int b)

int s = a - b;

return s;

int multiplication (int a, int b)

int t = a*b;

return t;

int division (int a, int b)

int u = a/b;

return u;

int modulo (int a, int b)

int v = a%b;

return v;

int main()

int a, b;

cout<<"Input values for a and b \na: ";


cin>>a;

cout<<"b: ";

cin>>b;

int c = addition (a,b);

int d = subtraction (a,b);

int e = multiplication (a,b);

int f = division (a,b);

int g = modulo (a,b);

cout<<"The sum of the 2 integers is " <<c;

cout<<"\n\nThe difference of the 2 integers is "<<d;

cout<<"\n\nThe product of the 2 integers is "<<e;

cout<<"\n\nThe quotient of the 2 integers is "<<f;

cout<<"\n\nThe modulus of the 2 integers is "<<g;

You might also like