Ok this is more to do with laziness than anything else but I was wondering how would you create a program that cancels down fractions into its simplest form. I've managed to do it for positive integers but I have a problem when dealing with negative integers.
Remember these rules:
Possible solutions include using the absolute function, or perhaps converting the integer to a string and then checking to see if the first element in that array is equal to '-' or '+' and then doing the necessary arithmetic manipulations.
+ / + = +
+ / - = -
- / + = -
- / - = +
If you can see a quick easy solution, I would be most grateful.
Here's my code so far, note it only handles positive integers!
using namespace std;
cout<<"Enter top part of fraction:";
cout<<"Enter bottom part of fraction:";
for (int a=1; a<=smallest; a++)
cout<<"When cancelled down..."<<endl;