Table Q2 shows four countries and their population for 4 years (in millions). Given the main program in Figure Q2, answer the following questions: 2013 50.4 2014 2015 2016 KOREA REP 50.7 51.0 51.2 MALAYSIA 29.7 30.2 30.7 31.1 JAPAN 127.4 127.2 127.1 126.9 SINGAPORE 5.3 5.4 5.5 5.6 Table Q2 tinclude #define ROW 4 #define COL 4 float get_avg_msia (float[]); float get_total_pops (float [] [COL], int); using namespace std; int main (){ float pops [ROW] [COL]={{50.4, 50.7, 51.0, 51.2}, {29.7, 30.2, 30.7, 31.1}, (127.4. 127.2. 127.1. 126. 91.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter2: Basic Elements Of C++
Section: Chapter Questions
Problem 4SA
icon
Related questions
Question
QUESTION 2
Table Q2 shows four countries and their population for 4 years (in millions). Given the main
program in Figure Q2, answer the following questions:
2013
50.4
29.7
127.4
2015
2016
51.2
2014
KOREA REP
50.7
51.0
MALAYSIA
30.2
30.7
31.1
JAPAN
SINGAPORE
127.2
127.1
126.9
5.3
5.4
5.5
5.6
Table Q2
#include <iostream>
#de fine ROW 4
#define COL 4
float get_avg_msia (float[]);
float get_total pops (float [] [COL], int);
using namespace std;
int main () {
float pops [ROW] [COL]={(50.4, 50.7, 51.0, 51.2),
{29.7, 30.2, 30.7, 31.1},
{127.4, 127.2, 127.1, 126. 9},
(5.3, 5.4, 5.5, 5. 6}};
cout<<"Malaysia's average
population :"<<get_avg_msia (pops [1])<<"mil\n";
cout<<"Total population in
2015:"<<get_total_pops (pops, 2) <<"mil\n";
return 0;
float get_avg_msia (float p_m[]){
// complete the function definition
Figure Q2
a. Complete the function definition to compute the average of Malaysia population
throughout the years. The function call and function header is given in the program.
b. Write a function definition to compute the total population of all four countries in the year
of 2015. The function call is given in the program.
Transcribed Image Text:QUESTION 2 Table Q2 shows four countries and their population for 4 years (in millions). Given the main program in Figure Q2, answer the following questions: 2013 50.4 29.7 127.4 2015 2016 51.2 2014 KOREA REP 50.7 51.0 MALAYSIA 30.2 30.7 31.1 JAPAN SINGAPORE 127.2 127.1 126.9 5.3 5.4 5.5 5.6 Table Q2 #include <iostream> #de fine ROW 4 #define COL 4 float get_avg_msia (float[]); float get_total pops (float [] [COL], int); using namespace std; int main () { float pops [ROW] [COL]={(50.4, 50.7, 51.0, 51.2), {29.7, 30.2, 30.7, 31.1}, {127.4, 127.2, 127.1, 126. 9}, (5.3, 5.4, 5.5, 5. 6}}; cout<<"Malaysia's average population :"<<get_avg_msia (pops [1])<<"mil\n"; cout<<"Total population in 2015:"<<get_total_pops (pops, 2) <<"mil\n"; return 0; float get_avg_msia (float p_m[]){ // complete the function definition Figure Q2 a. Complete the function definition to compute the average of Malaysia population throughout the years. The function call and function header is given in the program. b. Write a function definition to compute the total population of all four countries in the year of 2015. The function call is given in the program.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Normalization
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning