1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
int num[5] // Missing the semi-colon. I would discourage global variables.
int x; // I would discourage global variables.
int y; //I would discourage global variables.
// This function is supposed to be determine the highest number.
// But it wont do it, because you are not comparing the numbers.
// The paremeter num1 is not being used inside the max function.
int max(int num1){
for (int z = 0; z<5; z++){
y = num[z];
// You may get an additional error due to putting multiple
// values into a single variable.
}
}
return y; // This return is outside the function max.
int main(){
cout << "Type Integers:" << endl;
for (x = 0; x<5; x++)
{
cin >> num[x]
}
cout << "The Highest Integer is:" << max(y) << endl;
return 0;
}
|
I broke the problem into parts that may give you a head start:
Create a program that holds an array containing 5 integers
for (define and initialize the counter; counter < Total Number of Integers; Increment the counter)
ask the user for the number input for every iteration;
The first method named lowest returns the lowest from the 5 numbers.
Define and initialize a variable with the first integer number to determine the lowest.
for (define and initialize the counter; counter < Total Number of Integers; Increment the counter)
if (iterated numbers by the counter < Defined and initialized a variable with the first integer number to determine the lowest.)
then, the Defined and initialized a variable with the first integer number to determine the lowest is equal to the lowest number in the iterated numbers by the counter.
The second method named highest returns the lowest from the 5 numbers.
Steps are similar to lowest, but use the > operator.
Your output should contain the original list of number
for (define and initialize the counter; counter < Total Number of Integers; Increment the counter)
display the output of the iterated numbers inputted by the user;
display the highest and the lowest number from the list.
Output the highest and lowest value of the list in cout statements.