Maximum Element in Array

What is wrong in the code written below i am getting compile-time Error…

#include
using namespace std;
int main() {
int arr[100];
cin>>“Enter the Size of the Arrar:”;
cin>>n;

for(i=0;i<n;i++){
    cin>>arr[i];
}
int max=0;
for(i=0;i<n:i++){
    if(max < a[i]){
        max = a[i];
    }
}
cout<<"Maximum Value in Array is:"<<max;

return 0;

}

Hello Neelmani,
you havent declared n in your code.

one more error - your are declaring array of size 100 so your code will given segmentation fault for n>100
to remove this do something as follows
int n;
cin>>n;
int arr[n];

if this resolves your doubt then please don’t forget to mark it resolved

i have corrected the both the mistakes

initialised n and changed the array size also still getiing the error

please share your updated code using coding blocks ide

hello @neelmani98 here is your working code https://ide.codingblocks.com/s/172562

errors-
a) if you check range of array element then u will find that int datatype will not be able to accomdate it.so i changed it to long long.
b) max value can be negative as well so instead of initialising it with zero intiialise it with any number in array (in my case it is arr[0])
c) you were outputiing "“Maximum Value in Array is:” which should not be as you are asked to print max value only