What is the difference between a pointer and an array in C?

What is the difference between a pointer and an array in C?

a) A pointer stores an address, an array stores multiple values
b) A pointer stores multiple values, an array stores an address
c) Both are the same in functionality
d) A pointer and an array cannot be used together

Answer:

a) A pointer stores an address, an array stores multiple values

Explanation:

In C, a pointer is a variable that stores the memory address of another variable, whereas an array is a collection of elements of the same data type stored in contiguous memory locations. While pointers and arrays are closely related, they serve different purposes. An array is used to store and access multiple values, whereas a pointer is used to directly access and manipulate memory. Although an array name can be used as a pointer to its first element, arrays and pointers are not interchangeable in all contexts.

Understanding the difference between pointers and arrays is important for effectively managing data storage and memory access in C programs.

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