Skip to content

vs code giving incorrect output #10319

@daminiip

Description

@daminiip
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int n;
    
    int bit=0;
    int i=0;
    int bin=0;
    cout<<"enter n: ";
    cin>>n;
    while (n!=0)
    {
        bit=n&1;
        bin=(bit*pow(10,i))+bin;
        n=n>>1;
        i++;
    }
    cout<<"the binary representation is "<<bin<<endl;
    
}

this is the code i'm trying to run. this is the required output that i'm getting on an online compiler.
enter n: 16
the binary representation is 10000

however on vs code, this is the output:
enter n: 16
the binary representation is 9999

Metadata

Metadata

Assignees

Labels

more info neededThe issue report is not actionable in its current statequestiontasks/build/debugAn issue relating to tasks.json (e.g. build issues)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions