#include<stdio.h> #include<conio.h> struct hi { int k1,k2; int m1,m2; } kil; main() { int a; printf("Enter the first distance in parts of kilometres and metres respectively\n"); scanf("%d",&kil.k1); scanf("%d",&kil.m1); printf("Enter the second distance in parts of kilometres and metres respectively\n"); scanf("%d",&kil.k2); scanf("%d",&kil.m2); printf("Select the operation\n1. Addition\n2. Subtraction\n3. Read\n4. Display\n5. Exit\n"); scanf("%d",&a); if(a==1) { printf("Addition - %d Kilometres & %d Metres",kil.k1+kil.k2,kil.m1+kil.m2); } else if(a==2) { printf("Subtraction - %d Kilometres & %d Metres)",kil.k1-kil.k2,kil.m1-kil.m2); } else if(a==3) { printf("Distances entered by you:\n1. %d Kilometres & %d Metres",kil.k1,kil.m1); printf("Distances entered by you:\n2. %d Kilometres & %d Metres",kil.k2,kil.m2); } else if(a==4) { printf("Distances entered by you:\n1. %d Kilometres & %d Metres",kil.k1,kil.m1); printf("Distances entered by you:\n2. %d Kilometres & %d Metres",kil.k2,kil.m2); } else if(a==5) { exit(1); } else { printf("Not a valid operation."); } }
Output:
I relish, cause I discovered just what I used to be taking a look for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye keedackkbdeeaeab