# Answer to Question #6379 in C++ for diviyah

Question #6379

International Book Fair which was held for 30 days attracted many visitors. Only those visitors with passes were allowed to enter. Number of passes issued for each day was recorded. Based on the records, write a C++ program that will analyze the success of the book fair. Your program should contain the following functions:

(a) main() function that contains instructions for reading input needed and prints all the related information.

(b) TOTAL() function that calculates the total visitors who went to the book fair.

(c) AVERAGE() function that calculates the average number of visitors.

(d) DAYS() function that calculates the number of days which has the number of visitors more than the average.

(a) main() function that contains instructions for reading input needed and prints all the related information.

(b) TOTAL() function that calculates the total visitors who went to the book fair.

(c) AVERAGE() function that calculates the average number of visitors.

(d) DAYS() function that calculates the number of days which has the number of visitors more than the average.

Expert's answer

#include <iostream>

using namespace std;

float total(float* n, float count){

float tot = 0;

for(int i = 0; i < count; i++)

& tot += n[i];

return tot;

}

float average(float n, float count){

float avg = 0;

avg = n/count;

return avg;

}

float days(float* n, float count, float avg)

{

float d = 0;

for(int i = 0; i < count; i++)

{

& if(n[i] > avg)

& d++;

}

return d;

}

void main()

{

float count = 0;

float t = 0, d = 0, n[50], avg = 0;

cout << "How many days lasted Fair? ";

cin >> count;

for(int i = 0; i < count; i++)

{

& cout << "how many people visited the " << i+1 << " day of the fair? ";

& cin >> n[i];

}

t = total(n, count);

avg = average(t, count);

d = days(n, count, avg);

cout << "\nThe total visitors who went to the book fair is: " << t << endl;

cout << "The average number of visitors is: " << avg << endl;

cout << "The number of days which has the number of visitors more than the average is: " << d << endl;

}

using namespace std;

float total(float* n, float count){

float tot = 0;

for(int i = 0; i < count; i++)

& tot += n[i];

return tot;

}

float average(float n, float count){

float avg = 0;

avg = n/count;

return avg;

}

float days(float* n, float count, float avg)

{

float d = 0;

for(int i = 0; i < count; i++)

{

& if(n[i] > avg)

& d++;

}

return d;

}

void main()

{

float count = 0;

float t = 0, d = 0, n[50], avg = 0;

cout << "How many days lasted Fair? ";

cin >> count;

for(int i = 0; i < count; i++)

{

& cout << "how many people visited the " << i+1 << " day of the fair? ";

& cin >> n[i];

}

t = total(n, count);

avg = average(t, count);

d = days(n, count, avg);

cout << "\nThe total visitors who went to the book fair is: " << t << endl;

cout << "The average number of visitors is: " << avg << endl;

cout << "The number of days which has the number of visitors more than the average is: " << d << endl;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment