fork download
  1. #include <stdio.h>
  2.  
  3. // Function to calculate total euros in the jar
  4. double calculate_total_euros(int two_euro, int one_euro, int fifty_cent, int twenty_cent, int ten_cent, int five_cent, int two_cent, int one_cent) {
  5. double total = 0.0;
  6.  
  7. total += two_euro * 2.0; // 2-euro coins
  8. total += one_euro * 1.0; // 1-euro coins
  9. total += fifty_cent * 0.5; // 50-cent coins
  10. total += twenty_cent * 0.2; // 20-cent coins
  11. total += ten_cent * 0.1; // 10-cent coins
  12. total += five_cent * 0.05; // 5-cent coins
  13. total += two_cent * 0.02; // 2-cent coins
  14. total += one_cent * 0.01; // 1-cent coins
  15.  
  16. return total;
  17. }
  18.  
  19. int main() {
  20. // Example input values
  21. int two_euro = 5;
  22. int one_euro = 2;
  23. int fifty_cent = 2;
  24. int twenty_cent = 5;
  25. int ten_cent = 15;
  26. int five_cent = 0;
  27. int two_cent = 0;
  28. int one_cent = 2;
  29.  
  30. // Call the function
  31. double total = calculate_total_euros(two_euro, one_euro, fifty_cent, twenty_cent, ten_cent, five_cent, two_cent, one_cent);
  32.  
  33. // Output the result
  34. printf("Total money in the jar: %.2f Euros\n", total);
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Total money in the jar: 15.52 Euros