#include"stdio.h"
#include"conio.h"
float a,b,c,d,r;
char op;
void main()
{
printf("Enter the 1st fraction and 2nd fraction\n");
scanf("%f",&a); printf("/"); scanf("%f",&b); scanf("%f",&c); printf("/"); scanf("%f",&d);
printf("Enter the opreter\n");
op=getche();
printf("\n");
while(op!='0')
{
switch(op)
{
case'+':
{
r=(a*d+b*c)/(b*d);
printf("Result is %f\n",r);
break;
}
case'-':
{
r=(a*d-b*c)/(b*d);
printf("Result is %f\n",r);
break;
}
case'*':
{
r=(a*c)/(b*d);
printf("Result is %f\n",r);
break;
}
case'/':
{
r=(a*d)/(b*c);
printf("Result is %f\n",r);
break;
}
}
printf("Enter the 1st fraction and 2nd fraction\n");
scanf("%f",&a); printf("/"); scanf("%f",&b); scanf("%f",&c); printf("/"); scanf("%f",&d);
printf("Enter the opreter\n");
op=getche();
printf("\n");
}
getch();
}
Home
books and codes
c
c++
calculator
code for calculator
fractions
code for making calculator for fractions
0 comments: