#1> This is some really old code laying around in the depths of my harddrive, but it should be exactly what you are looking for. It's not really a programming problem as much as a math problem, luckily Euclidean did all the work for us many years ago. Euclidean algorithm for finding the Greatest Common Denominator: void GCD(int &Nume, int &Denom) { int a= Nume; int b= Denom int temp = a % b; while (temp > 0) //Keep searching till a % b evenly { a = b; //Cycle Values b = temp; temp = a % b; } Nume= Nume / b; Denom= Denom /b; } #2> Ok, this one is easier than it seems. So lets say we the float 6.44 from the user. Now the easy part, casting a floating point into an integer will automaticall truncate the number, therefore leaving us with only the whole number, simple subtraction does the rest.
float f1 = 6.44f;
int Int1= (int) f1; //Truncate 6.44 to int 6
f1= f1 - Int1; // 6.44 -6 = 0.44