```
#include <stdio.h>
int main(void)
{
// Local Declarations
int num1, num2, num3, num4, num5;
int choice;
int smallest, largest;
int sum;
int average;
// Statements
printf("Please enter 5 numbers: ");
scanf("%d %d %d %d %d", &num1, &num2, &num3, &num4, &num5);
printf("======MAIN MENU====== \n");
printf("[1] Add \n");
printf("[2] Find the Average\n");
printf("[3] Find the smallest \n");
printf("[4] Find the largest \n");
printf("Enter your choice...");
scanf("%d", &choice);
switch(choice)
{
case 1 : sum = num1 + num2 + num3 + num4 + num5;
printf("The sum of the numbers are: %d\n", sum);
break;
case 2 : average = (num1 + num2 + num3 + num4 + num5) / 5;
printf("The average of the numbers are: %d\n", average);
break;
case 3 : // Finding the smallest
smallest = num1;
if (num2 < num1)
smallest = num2;
if (num3 < num2)
smallest = num3;
if (num4 < num3)
smallest = num4;
if (num5 < num4)
smallest = num5;
else if (num5 < num1)
smallest = num5;
printf("The smallest number is: %d\n", smallest);
break;
case 4 : // Finding the largest
largest = num1;
if (num2 > num1)
largest = num2;
if (num3 > num2)
largest = num3;
if (num4 > num3)
largest = num4;
if (num5 > num4)
largest = num5;
else if (num5 > num1)
largest = num5;
printf("The largest number is: %d\n", largest);
break;
default : printf("Invalid choice!\n");
}// end of switch
system("pause");
return 0;
}// main
```

Recommended Topics