compiler giving parse error at line 25 plzzzzz helppppp

#include<iostream>
using namespace std;
int MENU();
int TakeAction(int array[ ],int sizeofarray,int Caller);
int MAX(int sizeofarray,int array[]);
int MIN(int sizeofarray,int array[]);
int SecondHighest(int sizeofarray,int array[]);
int Reverse(int sizeofarray,int array[]);
int Output(int sizeofarray,int array[]);

int main()
{
int sizeofarray=0,n=0,input,Caller,temp;
cout<<"Enter the size of array (i.e. the no of elements tou want to enter)";
cin>>sizeofarray;
int array[sizeofarray];
while(n!=sizeofarray)
{
cout<<"enter element of array";
cin>>input;
array[n]=input;
n=n+1;
}
Caller=MENU();
TakeAction(int array[ ],int sizeofarray,int Caller); //ERROR IS HERE //25
return 0;
}

int MENU()
{
cout<<"Enter 1 to Output the array";
cout<<"Enter 2 to Find the Maximum value in the array";
cout<<"Enter 3 to Find the Minimun in the array";
cout<<"Enter 4 to Find the Second Highest in the array";
cout<<"Enter 5 to reverse the order of array";
int input;
cin>>input;
return input;
}
int TakeAction(int array[ ],int sizeofarray,int Caller) //40
{
int Max;
if(Caller==1)
Output(int sizeofarray,int array[ ]);
if(Caller==2)
{
Max=MAX(int sizeofarray,int array[ ]);
cout<<"Max number is array is"<<Max;
}
if(Caller==3)
MIN(int array[ ],int sizeofarray);
if(Caller==4)
SecondHighest(int sizeofarray,int array[ ]);
if(Caller==5)
Reverse(int sizeofarray,int array[ ]);
}
int MAX(int sizeofarray,int array[ ])
{
int n=0,max=array[n];
while(n!=sizeofarray)
{
if(array[n+1]>array[n])
max=array[n+1];
n=n+1;
}
return max;
}
Last edited on
Please use code tags when posting code.

Please be specific about the error your compiler is giving you.

Note that:

1
2
3
int sizeofarray=0;
cin>>sizeofarray;
int array[sizeofarray];


is not legal C++. If you want to declare an array like that, you need to do it with a constant size.

If the size is not known at compile-time - e.g. because you want the user to enter the size - then you need to dynamically allocate the array after the size has been determined.

TakeAction(int array[ ],int sizeofarray,int Caller);

This is a function declaration, not a function call. You should go back to your textbooks and remind yourself of the syntax for calling a function.
Last edited on
ok thankss...
but this is how our teacher told that we can call a function like this...
what i mean to say is i am not able to understand the error...what do u think should be the function call?
i have declared the function in the beginning

int TakeAction(int array[ ],int sizeofarray,int Caller);
now i want to call it...


and i am using gcc for compiling the program and it says " parse error before [ token"....thats all it says

again thanksss alottt..
Last edited on
Yes, you've declared it correctly at the start of the program. But in the line where you're trying to call it, you're not using the right syntax for calling the function. You're using the syntax for declaring a function instead.

Like I said before, go back to your textbook, and read up on how to call functions. It will only take you a few minutes, and it'll help you learn how to use functions properly.
yes thnkss i dont know why i was using int in the call...
but thnks again its fixed now..
You're welcome! Glad it worked out :)
Topic archived. No new replies allowed.