Programming
February 13, 2024Question 10826 – Algorithm-Paradigms
February 13, 2024Programming
Question 7 |
The following is an incomplete Pascal function to convert a given decimal integer (in the range -8 to +7) into a binary integer in 2’s complement representation. Determine the expression A, B, C that complete program.
function TWOSCOMP (N:integer):integer; var RAM, EXPONENT:integer; BINARY :integer; begin if(N>=-8) and (N<=+7) then begin if N<0 then N : = A; BINARY:=0; EXPONENT:=1; while N<>0 do begin REM:=N mod 2; BINARY:=BINARY + B*EXPONENT; EXPONENT:=EXPONENT*10; N := C end TWOSCOMP:=BINARY end end;
Theory Explanation. |
Correct Answer: A