Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <iostream>
  2. float cm;
  3. float inch;
  4. int valg;
  5.  
  6. float convert_to_inch()
  7. {
  8.     printf("Hvor mange cm vil du konvertere ti inches?");
  9.     scanf_s("%f", &cm);
  10.     inch = cm / 2.54;
  11.     printf("%f cm tilsvarer %f inches", cm, inch);
  12.     return 0;
  13. }
  14.  
  15. float convert_to_metric()
  16. {
  17.     printf("Hvor mange inches vl du konvertere til cm?");
  18.     scanf_s("%f", &inch);
  19.     cm = inch*2.54;
  20.     printf("%f inches tilsvarer %f cm", inch, cm);
  21.     return 0;
  22. }
  23.  
  24. int main()
  25. {
  26.     printf("Tast 1 for CM-INCHES\n Tast 2 INCHES-CM\n");
  27.     scanf_s("%d", &valg);
  28.     switch (valg)
  29.     {
  30.     case 1:
  31.         convert_to_inch;
  32.         system("Pause");
  33.     case 2:
  34.         convert_to_metric;
  35.         system("pause");
  36.     default:
  37.         break;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement