scanf requires the addressOf (&) operator because it takes a pointer as an argument. Therefore, in order to pass a variable that should be set to the passed value, you must make a pointer outside the variable so that it can be changed.
The reason the pointer should be passed to scanf is because if you just passed the variable, you cannot directly modify the variable in scanf, so you cannot set it to the value read with scanf.
Hope this helps.
Ethan source share