I thought the following codes were correct but it is not working.
int x, *ra;
&ra = x;
int x, ra;
&ra = x;
Your both expressions are incorrect, It should be:
int x, *ra; ra = &x; // pointer variable assigning address of x
Moreover as you question title suggests:
Assigning int value to an address.
ra is a pointer contains address of variable
x so you can assigning an new value to
*ra = 20;
* before pointer variable (in unary syntax) is deference operator gives value at the address.
int x = 10; int &ra = x; // reference at time of declaration
Accordingly in case of reference variable, if you wants to assign a new value to
x its very simple in syntax as we do with value variable:
ra = 20;
ra is reference variable we assigns to
* still change reflects, this is the benefit of reference variable: simple to use capable as pointers!)
Remember reference binding given at the time of declaration and it can't be change where pointer variable can point to new variable latter in program.
In C we only have pointer and value variable, whereas in C++ we have pointer, reference and value variable. In my linked answer I tried to explain differences between pointer and reference variable.