What does the `&` operator do in C?

What does the & operator do in C?

a) It returns the memory address of a variable
b) It performs a bitwise AND operation
c) It dereferences a pointer
d) It performs a logical AND operation

Answer:

a) It returns the memory address of a variable

Explanation:

The & operator in C, when used with a variable, returns the memory address of that variable. This operator is essential for working with pointers, as it allows a pointer to be assigned the address of a variable. For example, if int x = 10;, then int *ptr = &x; assigns the address of x to the pointer ptr. Understanding the & operator is crucial for working with pointers and memory management in C.

Knowing how to use the & operator is fundamental for dynamic memory allocation, passing variables by reference, and efficient data handling 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