Why do you require ampersand (&) in the scanf
function. What will the output or type of error (compile or runtime) be in the following C code?
If you're asking a question like this, I would recommend just learning for now "it just does".
You will learn that you need an ampersand because scanf
takes one or more pointer arguments. If a is an int variable, it is not a pointer. &a ("the address of a") is a pointer, so it will work with scanf
.