What does the & operator do in C when used with a variable?

What does the & operator do in C when used with a variable?

a) It returns the address of the variable
b) It multiplies the variable by a constant
c) It adds two variables
d) It divides the variable by a constant

Answer:

a) It returns the address of the variable

Explanation:

The & operator in C, when used with a variable, returns the memory address of that variable. This operator is known as the “address-of” operator. It is commonly used in conjunction with pointers, allowing the pointer to store the address of a variable. For example, if int x = 10;, then int *ptr = &x; will store the address of x in the pointer ptr. Understanding how to use the & operator is essential for working with pointers and managing memory effectively in C.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top