@rahul sharma 5 BCD would take more space than regular binary, even if it is more convenient.

Dark Mode

5,539 views

56 votes

Best answer

I assume byte addressable memory- nothing smaller than a byte can be used.

We have four digits. So, to represent signed 4 digit numbers we need 5 bytes- 4 for four digits and 1 for the sign (like -7354). So, required memory = 5 bytes

Now, if we use integer, the largest number needed to represent is 9999 and this requires 2 bytes of memory for signed representation (one byte can represent only 256 unique integers).

So, memory savings while using integer is $\frac{(5 - 2)}{5} = \frac{3}{5} = 60\%$

Correct Answer: $C$

We have four digits. So, to represent signed 4 digit numbers we need 5 bytes- 4 for four digits and 1 for the sign (like -7354). So, required memory = 5 bytes

Now, if we use integer, the largest number needed to represent is 9999 and this requires 2 bytes of memory for signed representation (one byte can represent only 256 unique integers).

So, memory savings while using integer is $\frac{(5 - 2)}{5} = \frac{3}{5} = 60\%$

Correct Answer: $C$

Note:

Here if we store “-7354” in form of **characters, in** “-7354” there are 5 characters : $\{ \ ’- ’,’7’,’3’,’5’,’4’\}$

So for each character we need 1 byte. Therefore total memory reqd for 5 characters → 5B

Here if we store $-7354$ in form of **numbers, in** $-7354$ the number $7354$ as integer will require $14$ **bits** to be represented (as $2^{13} = 8192$) we can take one more **bit** to store sign (e.g. it’s -ve no. so we will use $1$ to represent it). Thus in total we need $15$ bits ≈ $2B$.

Therefore reduction = $5B-2B = 3B$

%redn = $3B/5B*100 = 60\%$

**ANSWER**: (**OPTION C)**

2

14 votes

signed four digit numbers

First position for the sign, the subsequent four positions for the digits.

__ __ __ __ __

It is common knowledge that 1 char takes 1 Byte. So, **this will take 5 Bytes**.

The size of int back in the day was 2 Bytes. Now it can take 4 Bytes with modern compilers. Since this is a 1998 question, let's assume the size of int is 2 Bytes :P So, **this whole integer takes 2 Bytes**.

Now the easiest part:

$\frac{5-2}{5}*100\%$

=> $60 \%$

**Option C**

Dennis Ritchie, Page number 36:

char [...] a single byte

and [the size of an] int [is] either 16 or 32 bits