Conver Decimal to Binary

I need your help in HOW TO CONVERT DECIMAL TO BINARY using Dev C++ version 4.9.9.2 . remarks: DO WHILE LOOPING and FOR LOOPING. please need your help. imma newbie in programing. T.T soo hard to think. i try and try but nothing i got.
~
LINK for Dev C++ version 4.9.9.2 download.
http://sourceforge.net/projects/dev-cpp/files/Binaries/Dev-C%2B%2B%204.9.9.2/
So what have you done so far?

These links may help:
http://www.cplusplus.com/doc/hex/
http://www.learncpp.com/cpp-tutorial/37-converting-between-binary-and-decimal/

Also as far as I know Dev is outdated. I would suggest a newer IDE such as Code::Blocks
i need an program that convert decimal number to binary number
We're not going to write your code for you. Have a go at writing it, and then if you run into specific problems, you can ask here for help with them.
http://www.wikihow.com/Convert-from-Decimal-to-Binary

here a link which will help u understand the algorithm of decimal to binary conversion...simply do it using c++ decisions and loops..

one while loop will do i hope......
#include <stdio.h>
#include <conio.h>

int main ()

{

int number,binary,decimal;
printf("Input a Decimal number:");
scanf("%d", &number);

while (binary<=number)
printf("the binary numbers are:\n");
number=number*2;
number++;

getch();
return 0;
}



can any1 help me. im looking for convirting binary numbers to decimal. im using while loop. how can i run this program -.-
Okay are you converting decimal to binary or binary to decimal you kind of contradicted yourself. Please use code tags as well. while (binary<=number) binary is undefined. Also you never use your "decimal" variable. As far as helping you, the greatest help would be to get you to understand the binary base because it looks like you are not sure what it is. Have you checked those links that I posted and that nomijigr posted?
yah. :-) thanks for all your links but the problem is that i dont know what to put in the while statement .... on how to convert decimal to binary and binary to decimal. can you state to me what are the missing statement -.-

my problem now is how to run the program. im looking for the while statement need your help.
Dev C++ version 4.9.9.2
- this is very outdated (2005).

Latest is Orwell DevC++ version 5.6.0 - updated January 25, 2014.
http://orwelldevcpp.blogspot.co.uk/


Last edited on
need your help pls. -.-
Best way to convert Decimal to binary is divide your number by two. If the remainder is 1, write that down, if 0, likewise. Then divide whatever your answer to the first problem was by 2 again. Repeat until you get down to 1 or 0.
there are two methods : the easy one with bitset and the hard one .

Heres the hard one:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int number;
    string bin;
    char holder=' ';
    cin>>number;
    while(number!=0)
    {
        holder=number%2+'0';
        bin=holder+bin;
        number/=2;
    }
    cout<<bin;
    return 0;
}
and heres the one with bitset(might have some extra zeroes though) :

#include <iostream>
#include <bitset>
using namespace std;

int main()
{
int number;
cin>>number;
bitset <16> bin(number);
cout<<bin;
return 0;
}
Topic archived. No new replies allowed.