The Garbage Value in C & C++ :-
When we make a variable declaration in programming languages such as C and C++ but do not set any value to it. Then that variable at that time like a waste material or garbage. But memory allocation has done at the creation time.
Here some condition is behind the garbage value:
1). When we explicitly define a variable in C or C ++, but no value is passed to them, then that variables are becoming like a garbage.
2). When we reach on extra indexes of an array and that array is on the stack, C or C++ will easily allow you to do that but it could generate the garbage. etc.
An Example for Garbage Collection -
printf(“\nValue of Variables Before Initialization a=%d,b=%d,c=%d”,a,b,c);//it printf the garbage value
printf(“\nValue of Variables After Initialization a=%d,b=%d,c=%d”,a,b,c);