menu driven program

You need to write a menu driven program.
The program allows a user to enter five numbers and then asks the user to select a choice from a menu. The menu should offer following options –
1. Display the smallest number entered

2. Display the largest number entered

3. Display the sum of the five numbers entered

4. Display the average of the five numbers entered.

5. Exit

You must use a "switch" statement in your code to determine what action to take. Provide an error message if an invalid choice is entered.
Run the program five times, once with each option and once with an invalid option. Each run is to use the following set of data (but your program needs to work with any five numbers entered by the user):
18, 21, 17, 44, 9.
Submit a word file with IPO, source code and the screenshots of the results of the five program runs.
If you are confused about anything here, please email me or call me. You can also post in the discussion forum (no code to be posted in the discussion forum) to get help from your peers.


here is my code cant get the largest and smallest values
/*
This is a menu driven program that prompts a user for either the smallest, largest, sum, or average for a group of 5 integers
Written by: James Raghubir
Date: July 13, 2018
*/


#include <stdio.h>
#include <stdlib.h>
#define firstChoice 1
#define secondChoice 2
#define thirdChoice 3
#define fourthChoice 4

/* The program allows a user to enter five numbers and then asks the user to select a choice from a menu.
The menu should offer four options. Use a switch function.
*/
main() {

int firstNumber, secondNumber, thirdNumber, sum;
int fourthNumber, fifthNumber, choice, average;


printf("Enter the first number: ");

scanf_s("%i", &firstNumber);
printf("Enter the second number: ");
scanf_s("%i", &secondNumber);
printf("Enter the third number: ");
scanf_s("%i", &thirdNumber);
printf("Enter the fourth number: ");
scanf_s("%i", &fourthNumber);
printf("Enter the last number: ");
scanf_s("%i", &fifthNumber);

printf("\nSelect the number of choice from the menu: \n");
printf("%i. Display the smallest number entered. \n", firstChoice);
printf("%i. Display the largest number entered. \n", secondChoice);
printf("%i. Display the sum of the five numbers entered. \n", thirdChoice);
printf("%i. Display the average of the five numbers entered. \n", fourthChoice);
scanf_s("%i", &choice);
sum = firstNumber + secondNumber + thirdNumber + fourthNumber + fifthNumber;
printf("%i", choice);
average = sum / 5;

switch (choice) {
case 1:
printf("The smallest number entered is: ");
break;
case 2:
printf("The largest number entered is: ");
break;
case 3:
printf("The sum of the five numbers is: %i", sum);
break;
case 4:
printf("The average of the five numbers entered is: %i", average);
break;
default:
printf("That is an invalid number. Please try again.");
}
getch();
return 0;

}








Topic archived. No new replies allowed.