Which of the following is the correct syntax for printing the address of the first element?

Question: Which of the following is the correct syntax for printing the address of the first element?

A        array[0]

B        array[1]

C         array[2]

D          None of the above

Answer:   array[0]

 

Programming Language Correct Syntax for Printing the Address of the First Element
C &array[0] or array (since the array itself can be used to refer to its address)
C++ &array[0] or array (similar to C)
Java In Java, you cannot directly access memory addresses as you can in C and C++. Memory management is abstracted from the programmer.
Python In Python, you can use the id() function to get the identity (memory address) of an object. For the first element of a list, you would use id(array[0]).
JavaScript In JavaScript, memory management is abstracted, and you cannot directly access memory addresses like in C or C++.