in quiz 1 i didn’t understand the code of ques 5
Regarding quiz 1
hello @smileygarg1
i dont have access to quizzes.
pls copy the quiz question in which u have doubt and paste it here
#include int main() { int N; std::cin>>N; if(N>=0) { int arr[N]; int max; for(int i=0;i<=N-1;i++){ std::cin>>arr[i]; if(arr[i]>-1000000000 && arr[i]<1000000000){ max=arr[0]; if(arr[i]>max) { max=arr[i]; } }} std::cout<<max; } return 0; }
…
this code is logicaly incorrect. here max is getting reinitialsied again n again after every iteration becuase of which it give wrong result in the end.