Checked similar questions but no one answers my problem.
This code :
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int n = 6;
    int bit = 0, answer = 0;
    int i = 0;
    while (n != 0) {
        bit = (n & 1);
        answer = answer + (pow(10, i) * bit);
        n = n >> 1;
        i++;
    }
    cout << "Binary equivalent is : " << answer;
    return 0;
}
this code works fine on Online compiler and gives expected result which is 110 but on VS code it is returning wrong answer without any visible error. What am i missing here?
Attaching the VS code and online gdb compiler result here : VS Code results
