Skip to content

Instantly share code, notes, and snippets.

@bc080401210
Last active October 26, 2016 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bc080401210/c7af6d8e33ca2c2952a83326cc3124ab to your computer and use it in GitHub Desktop.
Save bc080401210/c7af6d8e33ca2c2952a83326cc3124ab to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int val=23;
void intToBin(int var,int bitCount);
int main()
{
intToBin(23,8);
system("pause");
}
void intToBin(int var,int bitCount)
{
int i=0;
cout<<endl;
for(i = (bitCount - 1); i >= 0; i--)
{
cout<<((var & (1 << i))?'1':'0');
}
cout<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment