By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,483 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

convert ASCII to Binary /C

P: 4
can anyone tell me how can i convert
the ascii code: 48 to the binary number: 00110000
??

if anyone knows if there any other way to save the char of an ascii code 48 in a variable it would be great.

example:
i want to save the char of 48 as 0
and 49 as 1, 50 as 2... and so...
Nov 17 '06 #1
Share this Question
Share on Google+
1 Reply


100+
P: 111
Hai ayaniv

U have to % the No by 2 and get the remainder.

i = 48;

while(i>=0)
{
j = i%2;
printf("%d",j);
i = i % 2;
}
Nov 18 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.