Varying output for the same code

Question Link:
The same while loop gives a wrong answer on my VSCode (Windows, if that matters), while the same while loop is accepted on leetcode. What’s happening?
It is my first encounter with uint_32t, so I guess it has some relation to the WA?

#include<bits/stdc++.h>
using namespace std;

int main(){

    uint32_t n;
    cin>>n;
    int count = 0;

    while(n != 0){
        
        if(n & 1 == 1)
            count++;

        n = n >> 1;
    }

    cout<<count;

}

The input:
00000000000000000000000000001011
Gives me 8 on VSCode while the correct answer is 3.

For what input?

Please post the rest of the code.

1 Like

Done : D

1 Like

Wait?
Why are you giving a sequence of 0s and 1s as input?
It is supposed to read a decimal integer, right?

2 Likes

Jeez, just realized.
Yes, my bad.
Thanks a lot man :smiley:

1 Like