Consider the following C statements int a 24 int b 227 int

Consider the following C++ statements.
int a = 24;
int b = 227;
int c = a & b;
int d = a | b;
int e = a >> 4;
int f = b << 2;

(a) What is the 8-bit binary equivalent of decimal value 24?
(b) What is the 8-bit binary equivalent of decimal value 227?
(c) What is the value of c in binary and decimal?
(d) What is the value of d in binary and decimal?
(e) What is the value of e in binary and decimal?
(f) What is the value of f in binary and decimal?

*Please explain each one! Thanks.

Solution

a) What is the 8-bit binary equivalent of decimal value 24?
sol: binary value of 24 is 00011000

(b) What is the 8-bit binary equivalent of decimal value 227?
sol: binary value of 227 is 11100011

c)What is the value of c in binary and decimal?
sol: value of c in decimal is 0
value of c in binary is 00000000

here c=a&b it means we are doing logical and and operation on the a and b it means

c= 00011000 & 11100011

a: 00011000
b: 11100011
--------------
c: 00000000

d) What is the value of d in binary and decimal?

sol: value of d in decimal is 251
value of d in binary is 11111011

here d=a|b; it means sum of a and b

a: 00011000
b: 11100011
---------------
c: 11111011

e)What is the value of e in binary and decimal?
sol: value of e in decimal is 1
value of e in binary is 00000001

here value of a=24 its binary value is 00011000

e=a>>4 it means shift right operator so
   a: 00011000
   a>>4: 00000001
e: 00000001

f) What is the value of f in binary and decimal?
sol: value of f in decimal is 908
value of f in binary is 0000001110001100

here value of b=227 and it binary value is 11100011

   b:11100011
b<<2:1110001100
so f:1110001100

Consider the following C++ statements. int a = 24; int b = 227; int c = a & b; int d = a | b; int e = a >> 4; int f = b << 2; (a) What is the 8-
Consider the following C++ statements. int a = 24; int b = 227; int c = a & b; int d = a | b; int e = a >> 4; int f = b << 2; (a) What is the 8-

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site