dynamically allocated array of integers, computer science homework help
dynamically allocated array of integers, computer science homework help
Problem 1:
Write a program that:
- Asks the user to enter a size of an array
- Asks the user to enter a certain number of integers, based on the entered array size, separated by space
- Stores them using a pointer to a dynamically allocated array of integers.
- Then the program should print out the integers to the screen and print the average of even numbers and the average of odd numbers
Note: you can have averageEven(double a[ ], int size) and averageOdd(double a[ ], int size) as two functions that you invoke in your main method. Average of even numbers is the sum of even numbers divided by the number of even numbers in the array.
Problem 2:
Consider the class Country:
- Private:
- string countryCode;
- int population;
- int callCode;
- Public:
- Country(string countryCode, int population, int callCode);
- string getCountryCode();
- int getCallCode();
- int getPopulation();
Write a program that:
- Asks the user to enter a number of countries he wants to enter the data for
- Asks the user to enter the details of each country in a line separated by spaces (country code, population, call code) and create a dynamically allocated instance of Country based on that
- Enter each instance in a vector of Country*
- Sort the vector of Country* based on the population
- Display the countries’ data in descending order of their population
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


