7 7 votes What is the output of the following code?#include <stdio.h> int main() { int a[] = {2, 4, 6, 8, 10}; printf("%d %d %d", *a, *(a + 3), 3[a]); return 0; }$\texttt{2 6 8}$ $\texttt{2 8 8}$ $\texttt{4 8 10}$ $\texttt{Compilation error}$ Programming in C goclasses goclasses-cs-dpp goclasses-cs-dpp-day-304 programming-in-c c-programming goclasses-c-programming-practice-questions pointers array + – GO Classes 372 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes In C, the array name $\texttt{a}$ represents the base address of the array.So,$\texttt{a}$ means $\texttt{(a + 0)}$Therefore,$\texttt{*a = a[0] = 2}$Now,$\texttt{*(a + 3)}$ means value at index $\texttt{3}$.So,$\texttt{*(a + 3) = a[3] = 8}$Also,$\texttt{3[a]}$ looks unusual, but it is valid in C.Because:$\texttt{3[a] = *(3 + a)}$And this is the same as:$\texttt{a[3]}$So,$\texttt{3[a] = 8}$ $\therefore$ Output : $\texttt{2 8 8}$ Answer: B GO Classes answered Jun 22 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes HERE IS THE SIMPLE AND DETAILS EXPLANATION Prashant-G answered Sep 2 Prashant-G comment Share Follow 0 reply Please log in or register to add a comment.