fork download
  1. #include <stdio.h>
  2.  
  3. float calculateEuroTotal (int oneCent, int twoCent, int fiveCent,
  4. int tenCent, int twentyCent, int fiftyCent, int oneEuro, int twoEuro);
  5.  
  6. int main(void) {
  7.  
  8. float tempVar = 0;
  9. tempVar = calculateEuroTotal(2,0,0,15,5,2,2,5);
  10. printf("The value of myFloat is: %f\n", tempVar);
  11.  
  12. return 0;
  13. }
  14.  
  15. //**************************************************************
  16. // Function: calculateEuroTotal
  17. //
  18. // Purpose: Calculates the total value in euros based on the
  19. // number of coins of various denominations (e.g.
  20. // 1 cent, 2 cents, 1 euro, etc.) provided by the user.
  21. //
  22. // Parameters: oneCent - number of 1 cent coins
  23. // twoCent - number of 2 cent coins
  24. // fiveCent - number of 5 cent coins
  25. // tenCent - number of 10 cent coins
  26. // twentyCent - number of 20 cent coins
  27. // fiftyCent - number of 50 cent coins
  28. // oneEuro - number of 1 euro coins
  29. // twoEuro - number of 2 euro coins
  30. //
  31. // Returns: Total value in euros
  32. //**************************************************************
  33.  
  34. float calculateEuroTotal (int oneCent, int twoCent, int fiveCent,
  35. int tenCent, int twentyCent, int fiftyCent, int oneEuro, int twoEuro)
  36. {
  37.  
  38. // prepare total variable
  39. float euroTotal = 0.00;
  40.  
  41. // add one cent coins to total
  42. euroTotal += (oneCent * 0.01);
  43.  
  44. // add two cent coins to total
  45. euroTotal += (twoCent * 0.02);
  46.  
  47. // add five cent coins to total
  48. euroTotal += (fiveCent * 0.05);
  49.  
  50. // add ten cent coins to total
  51. euroTotal += (tenCent * 0.10);
  52.  
  53. // add twenty cent coins to total
  54. euroTotal += (twentyCent * 0.20);
  55.  
  56. // add fifty cent coins to total
  57. euroTotal += (fiftyCent * 0.50);
  58.  
  59. // add one euro coins to total
  60. euroTotal += (oneEuro * 1.00);
  61.  
  62. // add two euro coins to total
  63. euroTotal += (twoEuro * 2.00);
  64.  
  65. // return total variable
  66. return euroTotal;
  67.  
  68. } // calculateEuroTotal
  69.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
The value of myFloat is: 15.520000