Advertisement
Shailrshah

Addition of British and Metric Systems

Apr 19th, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. struct british
  3. {
  4.     float ft;
  5.     float in;
  6. }b1,b2;
  7. struct metric
  8. {
  9.     float m;
  10.     float cm;
  11. }m1,m2;
  12. int main()
  13. {
  14.     float a,b;
  15.     printf("Enter the values in m and cm\n");
  16.     scanf("%f%f",&a,&b);
  17.     m1.m=a;
  18.     m1.cm=b;
  19.     printf("Enter the values in ft and in\n");
  20.     scanf("%f%f",&a,&b);
  21.     b1.ft = a;
  22.     b1.in = b;
  23.  
  24.     b2.ft = m1.m *3.28;
  25.     b2.in = m1.cm *0.39;
  26.  
  27.     m2.m = b1.ft *(1/3.28);
  28.     m2.cm = b2.in *(1/0.39);
  29.  
  30.     printf("The addition is %.2f m and %.2f cm\n", m1.m+m2.m,m1.cm+m2.cm);
  31.     printf("The addition is %.2f ft and %.2f in", b1.ft+b2.ft,b1.in+b2.in);
  32.     return 0;
  33. }
  34. //Output
  35. //Enter the values in m and cm
  36. //5.67
  37. //7.11
  38. //Enter the values in ft and in
  39. //6.7
  40. //2.44
  41. //The addition is 7.71 m and 14.22 cm
  42. //The addition is 25.30 ft and 5.21 in
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement