Last active
October 26, 2016 08:55
-
-
Save bc080401210/c7af6d8e33ca2c2952a83326cc3124ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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