#include
using namespace std;
int main() {
int n;
int cs=0;
int ms=0;
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
cs=a[i];
if(cs>ms){
ms=cs;
}
}
cout<<ms;
return 0;
}
#include
using namespace std;
int main() {
int n;
int cs=0;
int ms=0;
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
cs=a[i];
if(cs>ms){
ms=cs;
}
}
cout<<ms;
return 0;
}
@be8036
Hello bharat
your code will give wrong answer when all element of array will be negative
for example
if array is -2 -3 -4 -5
then your code will output 0 which is wrong.
to rectify it check range of value that array element can take and then assign any value to ms which is less than range of array value