Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Consider the following program listing that is written in the C Language: #inc

ID: 2291208 • Letter: #

Question

. Consider the following program listing that is written in the C Language: #include void main(void); unsigned char a-0xF4; unsigned char b-0x4A unsigned char c,d,e,f; e-c&d; while(1); a) Are the declared data types local or global variables? b) Perform bitwise logical analysis to determine the unknown values of the given arithmetic and logic expressions c) Show the correct addresses and contents for all variables in the code listing. Hint: Draw/lllustrate the proper order of placing data into the specified memory locations!!!

Explanation / Answer

Answer :- a) The declared variables are local to the main function because these variables have been defined inside the function. The global variable is defined outside the function.

Answer :- b) The bitwise operation results are written below-

c = a | b => c = 0xF4 | 0x4A = 0b1111_0100 | 0b0100_1010 = 0xFE

d = a – b => d = 0xF4 – 0x4A = 0b1111_0100 – 0b0100_1010 = 0xAA

e = ~c & d => e = 0x01 & 0xAA = 0b0000_0001 & 0b1010_1010 = 0x00

f = ~e => f = 0xFF .

Answer :- c) The size of unsigned char variable is of one byte. So each varible will take one byte location in the memory. The address of varible is assigned randomly in the memory and we can see the address by using address operator i.e. &.