Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 11 v1.0
//gcc 5.4.0 #include <stdio.h> #include <string.h> typedef struct{ int n; int d; }fraction; int add(fraction a,fraction b){ int A,B,C,s; A=a.n*b.d; B=a.n*b.d; C=a.d*b.d; s=A+B; printf("{%d+%d)/%d=%d/%d",a,b,B,s,B); } int subtract(fraction a,fraction b){ int A,B,C,s; A=a.n*b.d; B=a.n*b.d; C=a.d*b.d; s=A-B; printf("{%d+%d)/%d = %d/%d",A,B,C,s,B); } int multiply(fraction a,fraction b){ int A,B; A=a.n*b.n; B=a.d*b.d; printf("{%d/%d)*(%d/%d) = %d/%d",a.n,a.d,b.n,b.d,A,B); return(0); } int divide(fraction a,fraction b){ int A,B; A=a.n*b.d; B=a.d*b.n; printf("{%d/%d)*(%d/%d) = %d/%d",a.n,a.d,b.n,b.d,A,B); } int main(void) { int o=0; while(o<1){ int c=0; fraction a; fraction b; //int v[4]; scanf("%d",&c); switch(c){ case 1: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); add(a,b); continue; case 2: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); subtract(a,b); continue; case 3: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); multiply(a,b); continue; case 4: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); divide(a,b); continue; case 5: printf("Goodbye :)"); o++; return(0); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Bool datatype Operation for GCC
A_141125_MenorMayor2
C)_Assign_q4
Stub Program for Problem 4 HW 2
PJE
TopTriangle.c
What happens if you do a system() in rextester...
Assignment 5 Cos(x)
B_141209_EsMayor
Project v0.07
Please log in to post a comment.