Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A traffic surveyor uses a program to analyze traffic flow on the Yellow Brick Br

ID: 3624505 • Letter: A

Question

A traffic surveyor uses a program to analyze traffic flow on the Yellow Brick Bridge over the course of a week. The program has been pre-loaded with the following daily traffic values in an array: 23, 55, 64, 52, 79, 66, 30. The program provides a recurring menu that allows the surveyor the choice of viewing the maximum, minimum or average traffic flow values for the week until the exit option is selected.

Write a C program on the above scenario. The program should make use of arrays and modular programming. Please make comments as necessary.

Explanation / Answer

#include #include int menu(); void max(int traficValues[]); int smallest(int traficValues[]); float average(int traficValues[]); int main(void) { int traficValues[7]={23, 55, 64, 52, 79, 66, 30};//pre-load int option; int Min; float avg; option = menu(); while(option!=4) { switch(option) { case 1: max(traficValues);/*could you either call a function or just write everything in the case*/ option = menu();// Ask user what they want to do next break; case 2: Min = smallest(traficValues); printf("Minimum trafic values: %d", Min); option = menu(); break; case 3: avg = average(traficValues); printf("Average trafic values of the week: %.1f", avg); option = menu(); break; case 4: printf("exit"); exit(101); break; default: printf("Incorrect Option. Please re-enter. "); option = menu(); break; } } return 0; } int menu(void) { int option; printf(" What would you like to do "); printf("1. View maxium trafic values "); printf("2. View minimum trafic values "); printf("3. Average trafic values "); printf("4. exit "); scanf("%d", &option); return option; } void max(int traficValues[]) { int i; int biggest; biggest = traficValues[0]; for(i=0; i biggest) biggest = traficValues[i]; } printf("Maxium trafic Values: %d", biggest); return; } int smallest(int traficValues[]) { int i; int smallest; smallest = traficValues[0]; for(i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote