I've been trying to make this code work for hours, but it's really messing my head up...
Its objective is simple, the user chooses how many numbers he wants to input, then the program output the highest.
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int returnHighest(int*,int);
int main()
{
int inputX;
cout<<"How many numbers do you wanna input? ";
cin>>inputX;
int listOfNumbers[inputX];
int n = 1;
while(n <= inputX)
{
int inputY;
cout<<"Input N. "<<n<<": ";
cin>>inputY;
listOfNumbers[n] = inputY;
n++;
}
cout<<"The highest number is: "<<returnHighest(listOfNumbers,inputX);
}
int returnHighest(int * list,int arraySize)
{
int returnValue;
//the following FOR loop will
//search for the highest int
//stored in "list" int array
int num = 0;
for(int x = 0 ; x <= arraySize; x++)
{
if(list[x] > num)
{
num = list[x];
}
}
returnValue = num;
return returnValue;
}