Question: c++ programming using namespace std nad Write a function printTotalMedals that takes an array for olympic sports and arrays for gold, silver, and bronze medals
c++ programming using namespace std nad
Write a function printTotalMedals that takes an array for olympic sports and arrays for gold, silver, and bronze medals and prints the total number of medals by discipline. Your function should take 5 parameters:
an array of strings disciplines
an array of ints representing the number of gold medals
an array of ints representing the number of silver medals
an array of ints representing the number of bronze medals
an integer size for the size of the arrays
Edge cases:
If the size < 1, print "Invalid size. Size must be at least 1."
example
const int SPORTS = 3; // number of sports/disciplines string disciplines[] = { "Figure Skating", "Speed Skating", "Short track" }; int gold_medals[SPORTS] = {1, 0, 0}; int silver_medals[SPORTS] = {1, 0, 0}; int bronze_medals[SPORTS] = {1, 2, 1}; printTotalMedals(disciplines, gold_medals, silver_medals, bronze_medals, 3); RESULT
Figure Skating: 3 Speed Skating: 2 Short track: 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
