The problem is that the *ptr has no values when you assign that to b.So it assigns the garbage value in the *ptr to b.After assigning that only you have get the value of a .Now that a's value will in the *ptr.
So you need to assign the pointer value to b after getting the input from the user.
int a , b; // if i put int a = 10 this will let me get value a=10 and b=10
ptr = &a;
// b = *ptr; // Wrong . Assigning the value in the pointer ( But a has no values so it gives the garbage values
b = *ptr; // Correct . Assigning the value in the pointer ptr.( Because now the *ptr has the value of a ).
printf("a = %d \n", a);
printf("b = %d \n", b); // i want to get 10 here