Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Translating binary to decimal numbers
#include<iostream> using namespace std; class number { private: int byte[8]; int sum; public: number() : sum(0) { } void binar() { for(int i=0;i<8;i++) { cin>>byte[i]; }} int btod() { if(byte[0]==1) sum+=128; if(byte[1]==1) sum+=64; if(byte[2]==1) sum+=32; if(byte[3]==1) sum+=16; if(byte[4]==1) sum+=8; if(byte[5]==1) sum+=4; if(byte[6]==1) sum+=2; if(byte[7]==1) sum+=1; return sum; } void decimal() { cout<<sum<<endl; } }; int main() { number s; s.binar(); s.btod(); s.decimal(); }
run
|
edit
|
history
|
help
0
Pairs having sum equal to target
Comp Conexe
Sample Code from Scott Meyer's Blog
Variadic Functor Example
Roger Cheng
New wall
C++ Solar eclipse program(Shoushi integrated) 1568 - 1644 also check Lunar eclipse for Xing Yunlu
Hello World
GRAPH DFS & BFS
Wipro Problem 1