Quote:

Originally Posted by **xpi0t0s**
Well, how would you do them on paper?

If a/b=14/20 and c/d=16/36, what's p/q (I got 103/90)? Show your working, and we can help you translate that working into an algorithm. Also show how far you got and where you're stuck, and we can help you with the next step.

Same goes for the second one. This one's a lot more interesting! Seems the key to this is to start with the long division algorithm you followed way back, you know where you write it out and solve it as follows:

Code:

14...etc
----------
7)1.0000000
7
---
30
28
--
2...etc

As you perform a couple of example divisions on paper, e.g. 1/7 and 3/8, can you see anything that your program should look for, in order to determine (a) if there is a loop and if so where from; (b) if the decimal expansion terminates.

well for the 1st program i have done some and have got a/b & c/d part clear out, see the code

Code:

#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c,d,i,lcm;
char ch;
clrscr();
printf("Enter 1st fraction: ");
scanf("%d%c%d",&a,ch,&b);
printf("Enter 2nd fraction: ");
scanf("%d%c%d",&c,ch,&d);
printf("Result: %d / %d",den,lcm);
end:;
getch();
}

now how can i take the lcm and how am i gona reduce the result to it's lowest forum??, here i am stuck