Error in code?

#include
#include
using namespace std;
int main ( ) {
int n ;
cin>>n;
int num;
int max = INT_MIN;
for(int i = 0;i<n;i++){
cin>>num;
if(num>max){
max = num;
break;
}
}
cout<<max;
return 0;
}

Hello @discobot,
Why haven’t you included header files with #include, like the header files which will be used here are #include and the other #include.
By including these two files it will run fine.
#include//this will be for input output
#include// This is for INT_MIN
using namespace std;
int main ( ) {
int n ;
cin>>n;
int num;
int max = INT_MIN;
for(int i = 0;i<n;i++){
cin>>num;
if(num>max){
max = num;
break;
}
}
cout<<max;
return 0;
}

Hi! To find out what I can do, say @discobot display help.

The correct code will be:
#include< iostream>//this will be for input output
include< climits>
using namespace std;
int main ( ) {
int n ;
cin>>n;
int num;
int max = INT_MIN;
for(int i = 0;i<n;i++){
cin>>num;
if(num>max){
max = num;
break;
}
}
cout<<max;
return 0;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

i have written the same code and it is still showing error output is not correct it is coming out as 4

hi @discobot dont use break in your code

removed break but the code is still not submiting

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.