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

convert decimal to binary

P: 1
Hi, this is sreelatha give a c progrm to convert decimal to binary....



thank u....
Aug 5 '07 #1
Share this Question
Share on Google+
5 Replies


Expert 10K+
P: 11,448
Hi, this is sreelatha give a c progrm to convert decimal to binary....



thank u....
We don't handout boiler plate code for you. You have to do your own homework
but when you're stuck we're very willing to help you. Please show us what
you've done sofar.

kind regards,

Jos
Aug 5 '07 #2

ilikepython
Expert 100+
P: 844
Hi, this is sreelatha give a c progrm to convert decimal to binary....



thank u....
This question has been asked multiple times before on these forums and you can easily find it on the internet.
Aug 5 '07 #3

P: 93
Hi, this is sreelatha give a c progrm to convert decimal to binary....



thank u....
Hint

make use of mod

if(n%2 == 0)
{
----
----
}
else
{
----
----
}

Regards,
Girish.
Aug 6 '07 #4

P: 6
take recursive function

fun(int n) {
static int rem;
if(n <= 0)
return ;
rem = n % 2;
fun(n/2);
printf("%d", r);
}
Aug 7 '07 #5

P: 3
Hi, this is sreelatha give a c progrm to convert decimal to binary....



thank u....
Here is the logic of decimal to binary convertion;
//before looping, after entering the decimal number
x=0;
quotient=DecNum/2;
remainder[x]=Decnum%2; // This is the initial binary number

//Inside loop
x++;
quotient=quotient/2;
remainder[x]=quotient%2;
// The loop will end if the value of the quotient will become <=1,
after the loop ends, you will have to reverse the order of remainder[x]
and display it.
Aug 8 '07 #6

Post your reply

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