Question: Create pseudocode and C++ code for a program that allows a user to enter 12 numbers. The numbers are to be stored in an array.

Create pseudocode and C++ code for a program that allows a user to enter 12 numbers. The numbers are to be stored in an array. After the numbers have been entered (and stored) the program will display the all the numbers as well as the largest number and the smallest number.

You will have 5 functions in this program:

int main()

void description()

void displayArray(int numbers[], int size)

int findLargest(int numbers[], int size)

int findSmallest(int numbers[], int size)

#include

using namespace std;

void description(); void displayArray(int numbers[], int size); int findLargest(int numbers[], int size); int findSmallest(int numbers[], int size);

THIS IS WHAT I HAVE SO FAR. BUT I KEEP GETTING 0 WHEN TRYING TO FIND THE SMALLEST NUMBER IN THE ARRAY.

int main() { int i; int largest; int smallest;

int size = 12; int numbers[12]; description(); for(i = 0; i < size; i++) { cin >> numbers[i]; } cout << " Your numbers are: "; displayArray(numbers, size); largest = findLargest(numbers, size); cout << " Largest number is: " << largest; cout << " Smallest number is: " << smallest; smallest = findSmallest(numbers, size); return 0; }

void description() { cout << "Enter any 12 numbers: "; }

void displayArray(int numbers[], int size) { int i; for(i = 0; i < size; i++) cout << numbers[i] << " "; }

int findLargest(int numbers[], int size) { int i; int great = numbers[0];

for(i = 1; i <= size; i++) { if(numbers[i] > numbers[0]) great = numbers[i]; }

return great; }

int findSmallest(int numbers[], int size) { int i; int smallest = numbers[0]; for(i = 1; i <= size; i++) { if(numbers[i] < numbers[0]) smallest = numbers[i]; } return smallest; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!