Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help a newbie out

Name: Anonymous 2012-04-01 10:14

Hello /prog/, I need a help in understanding this code, anyone willing to explain it in detail to an idiot?


(decimal to binary number)
int main()
{
int dec,rem,i=1,sum=0;
    cout<<"Enter the decimal to be converted:"<<endl;
    cin>>dec;
    do
    {
        rem=dec%2;
        sum=sum + (i*rem);
        dec=dec/2;
        i=i*10;
    }while(dec>0);
    cout<<"The binary of the given number is:"<<sum<<endl;
 
}

Name: Anonymous 2012-04-01 11:03

>>3
Big thanks.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List