//trying to find the highest final mark
#include <iostream>
#include <string>
usingnamespace std;
void findhighest(int studentp[],int finalmarkp[], float highestp, int countp)
{
highestp = 0;
for (int i = 0; i < number; i++)
{
if (finalmarkp[i] > highestp)
highestp = finalmarkp[i];
if (finalmark[i] >= 75)
countp++;
cout<<"Student number: "<<studentp[i]<<"Percentage: "<<finalmarkp[i]<<endl;
}
}
int main() //this part runs perfectly but with Function it does not
{
constint number = 5;
int student[number] = {102452,2541236,698745,147852,258963};
int finalmark[number];
float highest;
int count = 0;
for (int count = 0; count < number; count++) // getting input rainfall from user for each month
{
cout << "Enter highest mark for " << student[count] << ":";
cin >> finalmark[count];
}
findhighest(student, finalmark, highest, count);
return 0;
}
1) actually ask a question
2) use code tags (put your code inside of [code] and [/code])
3) tell us what the problem is. "It doesn't work" is too vague and does not tell us anything.
4) If you are getting a compiler error, tell us what the error is (preferably, paste the full error message) and tell us what line it's on
5) Otherwise, if the program compiles and does not do what you expect, tell us what you expect it to do, and tell us what it is actually doing.
You are trying to use 'number' and 'finalmark' inside of your findhighest function, but those variables only exist in main.
You are passing 'finalmark' to the function, which is good, but then it is named 'finalmarkp' inside findhighest. So you should be using that name. You will also need to pass 'number' to the function so you can use it there as well.
Also, I don't see why you need to pass 'highestp' and 'countp' to that function. They don't seem to do anything.