assistance with bool loop.

i have to write a bool function that checks the numerator to make sure its not a 0 and the symbol to make sure its a slash. if the conditions are met, the function shold return true. i need help setting up this function and using is. this is the code i have so far.

void addFractions (int num1, int denom1, int num2, int denom2);
void subtractFractions (int num1, int denom1, int num2, int denom2);
void multiplyFractions (int num1, int denom1, int num2, int denom2);
void divideFractions (int num1, int denom1, int num2, int denom2);


int main()
{
int num1;
int denom1;
int num2;
int denom2;
char slash;

cout << "Enter fraction x: ";
cin >> num1 >> slash >> denom1;// This is where the user enters the first fraction.
'\n';
cout << "Enter fraction y: ";
cin >> num2 >> slash >> denom2;// This is where the user enters the
second fraction.


the bool function should be used where the first and second fractions are entered.
any ideas from anybody?
closed account (D80DSL3A)
Do you mean denominator != 0 to prevent division by zero ?

How about:
1
2
3
4
5
6
7
bool areValidValues(char oper, int denom)
{
    if( oper == '/' && denom != 0 )
        return true;
    else
        return false;
}
Last edited on
Topic archived. No new replies allowed.