Posts

Showing posts from February, 2018
For more Computer Science, Linux, C++ content visit ProgrammerCave
Follow us on Facebook | Instagram | Telegram

Contribute on Paypal

C++: Add binary numbers

Image
We will store the binary numbers in an array. We have to store the least significant bit at index 0 and most significant bit at last index.  In   1 0 1 0  -  1 is the most significant bit and 0 is the least                         significant bit So it will be stored as  0 1 0 1 in array   C++ implementation to add binary numbers #include <iostream> #include <vector> #include <algorithm> void add(std::vector< int > & A,          std::vector< int > & B,          std::vector< int > & C) {    int size_A = A. size() ;    int size_B = B. size() ;    int max_size = (size_A >= size_B) ? size_A : size_B;    int carry = 0, sum = 0;  ...
For more Computer Science, Linux, C++ content visit ProgrammerCave
Follow us on Facebook | Instagram | Telegram

Contribute on Paypal