I just realized that i actually do not need this function at all becasue I

already have a GCF function, which will determine the gcf obviously, and if

a gcf is great than 1, then it is reducable, is that correct?

"Buster Copley" <bu****@none.com> wrote in message

news:bg**********@news6.svr.pol.co.uk...

Luis wrote: I am trying to write a program that checks to see if a fraction is

reducable, and to do this both numerator and denominator cannot be tre(

prime) will this work? if not can some one fix it up a bit for me?
thanks.

What does 'tre (prime)' mean?

That both the numerator and denominator are prime is a sufficient but

unnecessary condition for the fraction to be in its lowest terms.

Consider three-quarters.

# include <iostream.h>

using namespace std;

int main()

{

int numerator;

int denominator;

bool denom;

bool numer;

cin >> numerator;

You didn't initialise 'numer'. It is undefined whether even one

iteration of this loop will be done.

for (int numCount = 2; numCount <= numerator / 2 || numer == false;

numCount ++) {

if(numerator % numCount == 0)

{

numer = false;

break;

}

else

{

numer = true;

}

}

Rather than using a separate flag, you could test how far the loop got

by checking the value of numCount afterwards. (Of course, you would have

to move the declaration of numCount above the for statement.)

cout << numer;

return 0;

}

A fraction is reducable if its numerator and denominator are coprime,

that is, if their greatest common divisor is 1. Use Euclid's algorithm

to calculate a gcd.

It seems one of your class mates sought help here yesterday (on Monday).

You might find something useful in the replies he got.

Good luck,

Buster