You are on page 1of 1

#include <stdio.

h>
#include <conio.h>
typedef struct
{ int a;//pembilang
int b ;//penyebut
} pecahan;
void main ()
{
pecahan p1,p2,p3;
printf ("Pecahan Pertama\n");
printf ("a = ");scanf ("%d",&p1.a);
printf ("b = ");scanf ("%d",&p1.b);
printf ("\nPecahan Kedua\n");
printf ("c = ");scanf ("%d",&p2.a);
printf ("d = ");scanf ("%d",&p2.b);
printf ("\nJika a/b dan c/d maka : \n");
p3.a = (p1.a*p2.b)+(p1.b*p2.a);
p3.b = (p1.b*p2.b);
printf ("\na/b + c/d = %d/%d\n",p3.a,p3.b);
p3.a = (p1.a*p2.b)-(p1.b*p2.a);
p3.b = (p1.b*p2.b);
printf ("a/b - c/d = %d/%d\n",p3.a,p3.b);
p3.a = p1.a*p2.a;
p3.b = p1.b*p2.b;
printf ("a/b x c/d = %d/%d\n",p3.a,p3.b);
p3.a = p1.a*p2.b;
p3.b = p1.b*p2.a;
printf ("a/b : c/d = %d/%d\n",p3.a,p3.b);
getch ();
}