Skip to content

Instantly share code, notes, and snippets.

@mohnoor94
Last active August 20, 2017 21:27
Show Gist options
  • Select an option

  • Save mohnoor94/48a46aa8e67285ddbc27ef3eb14beeb8 to your computer and use it in GitHub Desktop.

Select an option

Save mohnoor94/48a46aa8e67285ddbc27ef3eb14beeb8 to your computer and use it in GitHub Desktop.
A full C++ program contains a function that takes 2 integer variables x and y, returns the multiplication of x and y in variable mul, and the division of x and y in variable div.
// www.abukhleif.com
#include <iostream>
using namespace std;
void multiplyAndDivide (int x, int y, int& mul, double& div) {
mul = x * y;
div = (x * 1.0) / y;
}
int main() {
int n1, n2, m;
double d;
cin>> n1 >> n2;
multiplyAndDivide(n1, n2, m, d);
cout<< n1 <<" * " << n2 << " = " << m << endl
<< n1 <<" / " << n2 << " = " << d << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment