Program:
please find the below program to find the maximum subscriptions for a journal and number of subscribers.
#include <iostream>
using namespace std;
//declaring constant variable
const int NUM_PUBS = 50;
//declaring the findMostSubs function
void findMostSubs(string publications[], int subscriptions[], int
nMostSubscriptions, string mostSubscriptions);
//defining the findMostSubs function
void findMostSubs(string publications[], int subscriptions[], int
nMostSubscriptions, string mostSubscriptions)
{
//declaring an integer variable to store the maximum subscriptions
in the array
int index = 0;
//for loop to find the max element in an array -
subscriptions
for(int i =0;i<NUM_PUBS;i++)
{
if(subscriptions[i] > nMostSubscriptions) {
nMostSubscriptions = subscriptions[i];
index = i;
}
}
//given 2 arrays are parallel,
//hence we can use the index of Subscriptions array to fetch the
title name from publications array
mostSubscriptions = publications[index];
cout << "The name of the publication that has most
subscriptions is " << mostSubscriptions << endl;
cout << "The number of subscribers to " <<
mostSubscriptions << " are " <<
nMostSubscriptions;
}
int main()
{
//declaration of an array to store titles of the
publications.
//here i'm initializing the arrays statically
string publications[NUM_PUBS] = {"Newyork
Times","HelloAPP","TimesNow","The Hindu", "missouri",
"LondonTimes",
"USA Today","The Wall Street Journal","New York Post","Los Angeles
Times", "The Washington Post",
"Star Tribune", "Newsday", "Chicago Tribune", " The Boston Globe",
"Alaska", "Bloomsberg",
"India Today", "Inshorts", "Quora", "Mediumdigest", "ABC",
"Stockexchange", "UK Today", "Alabama",
"Economic Times","Arizona", "phoenix", "california", "colorado",
"Georgia","florida", "Hawaii", "Indiana",
"Mississippi", "New Jersey", "Newyork", "New Mexico","Financial
Times","The Daily Telegraph","The Times",
"The Sunday Times", " The Guardian", "IEE journal", "Nature",
"Finance Management", "Nature Nano technology",
"Environmental research","Journal of Cancer","Journal of
Biosciences"};
//declaration of an array to store titles of the
subscriptions.
int subscriptions[NUM_PUBS] = {3,20,20,40,60,1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 3, 12, 4,12,
46, 90, 10,23, 3, 345,4, 17,
50,21,23,31,32,24,25,65,43,27,87,67,90,0,2,43,54,65,76,87,98,79};
//declaring a integer variable to store number of subscriptions
for publication with most subscriptions
//initializing the number of subscriptions as 0
int nMostSubscriptions=0;
//declaring a string varibale to store title of publication with
most subscriptions
//initializing the mostSubscriptions as empty string.
string mostSubscriptions="";
//calling findMostSubs function
findMostSubs(publications, subscriptions, nMostSubscriptions,
mostSubscriptions);
return 0;
}
Output:
QUESTION 3 13 marks In this question you have to write a complete function. MyMedia Publishers...
QUESTION 3 13 marks In this question you have to write a complete function. MyMedia Publishers uses two parallel arrays to keep track of the number of subscriptions for each of their 50 publications. Array publications holds the names of the magazines and newspapers published and array subscriptions holds the number of subscriptions for each corresponding magazine or newspaper. You have to write a void function, called fi ndMost Subs to determine which publication has the most subscribers. Function findMbst...
In this question you have to write a complete function. MyMedia Publishers uses two parallel arrays to keep track of the number of subscriptions for each of their 50 publications. Array publications holds the names of the magazines and newspapers published and array subscriptions holds the number of subscriptions for each corresponding magazine or newspaper. You have to write a void function, called findMost Subs to determine which publication has the most subscribers. Function findMost Subs has to return the...
In this question you have to write a complete function. in C++ MyMedia Publishers uses two parallel arrays to keep track of the number of subscriptions for each of their 50 publications. Array publications holds 1) the names of the magazines and newspapers published and array subscriptions 2)holds the number of subscriptions for each corresponding magazine or newspaper. You have to write a void function, called findMostSubs to determine which publication has the most subscribers. Function findMostSubs has to return the name of the publication as well as the number of subscribers to that publication. Assume the following: • a declaration of a global constant: const...
Define an ordinary function called DisplayMin that has three parameters: the first two parameters are parallel arrays of different types and the third argument is of type size_t representing the size of both arrays. The function DisplayMin must work when called with various types of actual arguments, for example string DisplayMin(string names[], int calories[], int size) or int DisplayMin(int calories[], float prices[], int size). (Parallel Arrays are two arrays whose data is related by a common index. For example: with...
This project will allow you to practice with one dimensional arrays, function and the same time review the old material. You must submit it on Blackboard and also demonstrate a run to your instructor. General Description: The National Basketball Association (NBA) needs a program to calculate the wins-losses percentages of the teams. Write a complete C++ program including comments to do the following: Create the following: •a string array that holds the names of the teams •an integer array that...
In C++ format: Define a function called DisplayMax. It will have 3 parameters of two different types of known parameter lists which are either void DisplayMax(string idI, double value[], int size) or void DisplayMax(int idn, short value几int size). The first and second parameters are parallel arrays. (Parallel Arrays are two arrays whose data is related by a common index. For example: with the string array and double array, index 5 of the string array would have some name, and index...
Assume you have the following declaration (in main) : int num[10] [7]; Assume that array num is filled completely. Write functions to perform each of the following: a) A function that prints all elements in the array that are greater than 10 or less than 50. b) A function that finds the largest number in the array and returns its subscript. c) A function that finds and returns the average of all the numbers in the array. d) A function...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main() function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of amain () function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the...
Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std; int read_function(int array[], int, int); int main() { int array[300], numba; read_function(array[300]); cout << "Enter a whole number between 2-20: " << endl; cin >> numba; read_function(numba); return 0; } int read_funtion (int arr[300], int num, int Values) { int sum=0; ifstream array_file; array_file.open("Lab8.dat"); for(int i=0; i < 300; i++) { array_file >> arr[i]; cout << arr[i]; sum += i; } cout << sum;...