Why does this code gives garbage value for negative 'no'?

int main(){
int i=1,n,no,largest=INT_MIN;
cin>>n;
while(i<=n){
cin>>no;
if(no>largest){
largest=no;
}
i=i+1;

}
cout<<“the largest number”<<largest;
}

hi @sbhardwaj1be21_2a991b329433c059 just cout largest no
like cout<<largest; not whole line
and use no>=largest eg 2 5 5

@talhashamim001 Sir, https://online.codingblocks.com/app/player/246132/content/235743/5026/code-challenge

I did the corrections , still it’s showing a garbage value for negative no.s, kindly guide.

hey @sbhardwaj1be21_2a991b329433c059 its passing all test case when i checked it please can u refer this https://ide.codingblocks.com/s/666457 (its ur code with correction)

Yes, it’s working . Thanks

@sbhardwaj1be21_2a991b329433c059 cool!!!

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.