c Please read the whole question and instrucions The instruc

c++

Please read the whole question and instrucions.

The instructor wants a function to convert string to int to perform the bitwise operations then convert int to string back again to show results.

Question:Write a program that produces the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
1001 0011 1011 and 1111 1010 0000.

Thank you in advance.

Solution

#include <iostream>
#include <string>
#include <cstdlib>

int main() {

    std::string input1 = \"100100111011 \" ;
    std::string input2 = \"111110100000\";

long int i1 = std::stol(input1);
    long int i2 = std::stol(input2);
long int c = 0;

  
   c = i1 & i2;  
   std::cout << \"Line 1 - Value of Bitwise AND is : \" << c << \'\ \' ;

   c = i1 | i2;           
   std::cout << \"Line 2 - Value of Bitwise OR is: \" << c << \'\ \' ;

   c = i1 ^ i2;            
   std::cout << \"Line 3 - Value of Bitwise XOR is: \" << c << \'\ \' ;
   
        
   return 0;
}

c++ Please read the whole question and instrucions. The instructor wants a function to convert string to int to perform the bitwise operations then convert int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site