# What is Garbage Value?

By Mandeep Kumar|Updated : September 5th, 2022

In language C, the Garbage value is defined as the leftover value from the previous programme contained in the block of the memory that has been allocated to the variable. To avoid this, the variable should be declared and initialized like int. x = 0.

In the case of Windows, the maximum negative value that can be stored by the variable of int data type is 2^15=-32768 is a garbage value. 2^15 is taken not 2^16 because one bit is reserved for sign (+ or -).

## Garbage Value Formula

The formula of garbage value is garbage value = overflow value - reference value. A reference value is defined as the value which is greater than the overflow value neglecting the sign. It is obtained by multiplying the basic reference value by 2 until the value is greater than the overflow value neglecting the sign. The reference value has the same sign as that of the overflow value.

Related Questions:-

write a comment

## FAQs

• A small block of memory is allocated to the variable, where the variable is not declared but initialized. The block of memory allocated to the variable contains some value that has been left over from the previous programme. It is called garbage value.

• The formula to calculate garbage value is garbage value = overflow value - reference value. The reference value is the value that is greater than the overflow value neglecting the sign.

### IAS

UPSC GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com