Good day. There is a task for bitwise operations. Conditions of the problem:
- Calculate R = A & B and check the transfer to decimal midrange.
- Calculate R = A | B and check the transfer to decimal midrange.
- Calculate R = A ^ B, Q = R ^ B and check by transferring to decimal midrange.
- Calculate R = ~ A, Q = ~ R.
- Calculate A >> c, B >> d and check by division.
- Calculate A << d, B << c and check by multiplication.
I, with my knowledge, could only make the first condition (Calculate R = A & B and check by transferring to decimal midrange), and that is not completely. Below is my code. How can it immediately implement all the conditions of the problem with the translation into the decimal MF? Thank you in advance.
#include "stdafx.h" #include <locale.h> #include <conio.h> int main() { setlocale(0,""); int A, B; printf("\nEnter A: A = "); scanf_s("%d",&A); printf("\nEnter B: B = "); scanf_s("%d",&B); printf("\nA & B = %d",A&B); getch(); return 0; }
A&Bonly need to writeA|B,A^B,~A,A>>c,A<<d. You can convert to the decimal system, but you already didprintfalong with%d(%dmeansdecimal, that is, the decimal number system). - Arty OneSoul