#include <stdio.h>
int main ()
{ // <--------- Scope 1 Begin
int y=10; >
{ // <--------- Scope 2 Begin
y=4;> this variable
printf("%d\t",y);>Output = 4
} // <-------- Scope 2 End
printf("%d",y);>Output = 4
} // <-------- Scope 1 End
In your first program here, you modify the y variable that you created in Scope 1. The second scope effectively does nothing here, as you still modify the original y from Scope 1. There is only one variable that was created here.
#include <stdio.h>
int main()
{ // <--------- Scope 1 Begin
int y=10;>
{ // <--------- Scope 2 Begin
int y=4;> > this variable
printf("%d\t",y); >Output = 4<
} // <-------- Scope 2 End
printf("%d",y); > Output = 10 this output differ <
} // <-------- Scope 1 End
However, in your program 2, by adding int before y=4 in Scope 2, you are instead initializing a new variable instead of assigning to y from Scope 1. This means that you are not modifying the y variable declared in Scope 1 when you do int y=4 from within Scope 2. As a result, the first y has the same value as when it was initialized. There are two variables that were created here.
As for memory usage, you can't really be sure without looking at the assembly output. It could be pushed and popped from the stack, or it could be optimized into a register, or it could even be removed altogether with a printf call with a literal.