HOME | DD

Published: 2007-08-15 16:38:20 +0000 UTC; Views: 61; Favourites: 0; Downloads: 1
Redirect to original
Description
#include#include
#include
int main (void)
{
int dec=0,bin[7],oct[2],hex[2],b,o,h,quo;
cout << "Decimal\t\tBinary\t\tOctal\t\tHexadecimal\n\n";
for(;dec<=255;dec++)
{ quo=dec;
b=0;
o=0;
h=0;
cout << dec;
// BINARY OUTPUT
if (quo==0)
bin[0]=0;
else while (quo>0&&b!=8)
{ bin[b]=quo%2;
quo=quo/2;
b++;
if (quo==0)
{ bin[b]=quo%2;
b--; }
}
cout << "\t\t";
for(;b>=0;b--)
cout <
quo=dec;
// OCTAL OUTPUT
if (quo==0)
oct[0]=0;
else while (quo>0&&o!=3)
{ oct[o]=quo%8;
quo=quo/8;
o++;
if (quo==0)
{ oct[o]=quo%8;
o--; }
}
if (dec<128)
cout << "\t\t";
else
cout << "\t";
for(;o>=0;o--)
cout <
quo=dec;
// HEX AHHHH DECIMAL
if (quo==0)
hex[0]=0;
else while (quo>0&&h!=3)
{ hex[h]=quo%16;
quo=quo/16;
h++;
if (quo==0)
{ hex[h]=quo%16;
h--;
}
}
cout << "\t\t";
for(;h>=0;h--)
{ if (hex[h]>9)
switch(hex[h]) {
case 10: cout << "A";
break;
case 11: cout << "B";
break;
case 12: cout << "C";
break;
case 13: cout << "D";
break;
case 14: cout << "E";
break;
case 15: cout << "F";
break; }
else
cout <
// HEX OUTPUT
cout <<"\n";
}// for loop (one line per loop)
cout << "\n\n";
system("PAUSE");
return 0;
}
// dies on the inside x_x
// this program took way too long to figure out for such simple coding. >_>
Related content
Comments: 8
lastKRYPT [2007-08-17 18:26:17 +0000 UTC]
wow then. "simple coding"? pshhh...this is freaking hard. but it's probably since i haven't coded anything except our skin at pictorial. 8]
👍: 0 ⏩: 1
Apos In reply to lastKRYPT [2007-08-18 21:30:10 +0000 UTC]
Nah, it's not that bad. The skin at Pict seems so much harder to code than this. x_x
👍: 0 ⏩: 0
lastKRYPT [2007-08-15 17:30:35 +0000 UTC]
dA's going wack. o_o i can't see anything except a bunch of coding.
👍: 0 ⏩: 1
Apos In reply to lastKRYPT [2007-08-16 00:35:23 +0000 UTC]
Well duh, the code's my deviation. :b My C++ assignment from yesterday. So annoying, but I figured it out in the end. (:
👍: 0 ⏩: 0
Apos In reply to surfersquid [2007-08-16 00:32:29 +0000 UTC]
xD Why are you people responding to this?! xD You're all crazy!
It's a program I wrote in C++ class, lol. It took me forever to figure it out, and today I finally did it. ..^^
I was so proud I had to submit it to dA! Hehe.
👍: 0 ⏩: 1
surfersquid In reply to Apos [2007-08-16 00:35:25 +0000 UTC]
Okay, that explains why I couldn't understand a lick of it. xD
👍: 0 ⏩: 1
Apos In reply to surfersquid [2007-08-16 00:40:25 +0000 UTC]
Aw, what's not to understand about it? All it is is just some basic nested C++ loops. :b
👍: 0 ⏩: 0