you can do
char myfunc(int &i, char c){
//do whatever you want
return c;
}
the reference & transfers the actual variable and not just the value within the variable, so any changes you make to i will also happen to you variable you plug in for example
char myfunc(int & i, char c){//declare the actual execution below main
i++;
return c++;
}
int main(){
int i = 0;
char c = 'a';
myfunc(i,c);
std::cout << i << " "<< c; // the output is 1 b
}
cin.ignore(); // no system functions
return 0;
}
that seems to work, you can put in
if( denum1 == denum2) num_answer = num1 + num2;
and similar statements to allow your program to be more efficient, you need to know about division of integers, and to include num1/(num2 * 1.0) in order to get a float. if you want it to stay in fraction form it is required to convert the values of each fraction to the required denominators are the same, easiest way to do this is
num1 *= denum2;
num2 *= denum1;
int hold = denum1;
denum1 *= denum2;
denum2 += hold;
int sumnum = num1+num2;
int sumdenum = denum1+denum2;
if( sumnum % 2 == 0 && sumdenum % 2 == 0) {
sumnum /= 2;
sumdenum /= 2;
} // do this for numbers 2, 3, 5, 7.
that is the easiest way for fraction reduction, there also might be a function in the library math.h but i did not memorize that complete library.