When you write a function, any variables you create locally "hide" those outside the function with the same name:
int x = 666;
void foo()
{
cout << x << endl;
}
void bar()
{
int x = 333;
cout << x << endl;
}
void main()
{
int x = 111;
foo();
bar();
}
Will print
666
333
because the
bar
function hides the external variable
x
, and so does the
main
function.
So your
main
function declares a new local variable called
marks
:
int main()
{
string name, am;
int marks, avg, max, min, sum=0, mx, m, i;
which "hides" the external one. All references to
marks
inside the
main
function will refer to the local version which is not an array.
Worse, you then start trying to use the data in it without actually filling it with anything so even if you remove the local definition, your code still won't work properly!
I think you need to sit down and think carefully about what you are trying to do before you leap into code - that shows all the hallmarks of "diving straight in and coding" before working out what you need to do!
Have a look here, it may help:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]