Code is a fraction calculator.
include include int gcd(int a, int b) { while (b!=0){ int temp=b; b=a%b; a=temp; } return a > 0 ? a : -a; } int main() { int number; printf("Enter a number for my runtime.\nNumber :"); scanf("%d",&number); printf("Example:\n a\n---\n b\n c\n---\n d\nNow...!\n"); while(number--) { int up1,du1,up2,du2,upnum,dunnum; char operaton,dibi1,dibi2; printf("Type your operation like 1/2 (+-/) 3/4\nOperation :"); scanf("%d %c %d %c %d %c %d",&up1, &dibi1, &du1, &operaton, &up2, &dibi2, &du2); if(operaton=='+') { upnum=up1*du2+up2*du1; dunnum=du1*du2; } else if(operaton=='-') { upnum=up1*du2-up2*du1; dunnum=du1*du2; } else if(operaton=='') { upnum=up1*up2; dunnum=du1*du2; } else if(operaton=='/') { upnum = up1 * du2; dunnum = up2 * du1; } int divitior=gcd(upnum , dunnum); int simple_upnumber = upnum/divitior; int simple_dunnumber = dunnum/divitior; printf("%d/%d = %d/%d\n",upnum,dunnum,simple_upnumber,simple_dunnumber); } return 0; }

include
include
int gcd(int a, int b) {
while (b!=0){
int temp=b;
b=a%b;
a=temp;
}
return a > 0 ? a : -a;
}
int main()
{
int number;
printf("Enter a number for my runtime.\nNumber :");
scanf("%d",&number);
printf("Example:\n a\n---\n b\n c\n---\n d\nNow...!\n");
while(number--)
{
int up1,du1,up2,du2,upnum,dunnum;
char operaton,dibi1,dibi2;
printf("Type your operation like 1/2 (+-/) 3/4\nOperation :");
scanf("%d %c %d %c %d %c %d",&up1, &dibi1, &du1, &operaton, &up2, &dibi2, &du2);
if(operaton=='+')
{
upnum=up1*du2+up2*du1;
dunnum=du1*du2;
}
else if(operaton=='-')
{
upnum=up1*du2-up2*du1;
dunnum=du1*du2;
}
else if(operaton=='')
{
upnum=up1*up2;
dunnum=du1*du2;
}
else if(operaton=='/')
{
upnum = up1 * du2;
dunnum = up2 * du1;
}
int divitior=gcd(upnum , dunnum);
int simple_upnumber = upnum/divitior;
int simple_dunnumber = dunnum/divitior;
printf("%d/%d = %d/%d\n",upnum,dunnum,simple_upnumber,simple_dunnumber);
}
return 0;
}