it looks like this should be two different "for" loops
you forgot to declare z, temp and array[]
EDIT: don't forget if you initialize array[] within the function you need to include the aggregate
try this:
int z, i;
int temp = 0;
int array[10] = {0,0,0,0,0,0,0,0,0,0};
for (z = 0; z < 10; z++) {
cin >> array[z];
}
for (i = 0; i < 10; i++)
{
if (array[i] > temp)
temp = array[i];
}
this function would take no arguments, so you would declare it and call it as "function()"
SECOND EDIT: i was actually able to get a function like this to work, and it would look like this:
#include <iostream>
using namespace std;
void function();
int main() {
cout << "enter 10 numbers: " << endl;
function();
return 0;
}
void function () {
int z, i;
int temp = 0;
int array[10] = {0,0,0,0,0,0,0,0,0,0};
for (z = 0; z < 10; z++) {
cin >> array[z];
}
for (i = 0; i < 10; i++) {
if (array[i] > temp)
temp = array[i];
}
cout << "your largest number is: " << temp;
}
good luck out there man
tempstarts out as what ?? (see why you provide MCVE's? to avoid having to ask questions like that). And do you really want to march a comparison loop through elements you haven't even loaded yet ?