...
Sorting
October 7, 2023
Graphs
October 7, 2023
Sorting
October 7, 2023
Graphs
October 7, 2023

Arrays

Question 1

Consider the following C program.

#include 
int main ()  {
     int a [4] [5] = {{1, 2, 3, 4, 5},
                      {6, 7, 8, 9, 10},
                      {11, 12, 13, 14, 15},
                      {16, 17, 18, 19, 20}};
     printf (“%d\n”, *(*(a+**a+2) +3));
     return (0);
} 

The output of the program is _______.

A
19
Question 1 Explanation: 
Check out the step by step program and its output in the comment:
#include
int main()
{
int a[4][5] = { {1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
{16,17,18,19,20}
};
printf(“%d\n”,a); //880 (consider base address = 880)
printf(“%d\n”,*a); //880
printf(“%d\n”,**a); //1
printf(“%d\n”,**a+2); //3
printf(“%d\n”,a+**a+2); //940
printf(“%d\n”,*(a+**a+2));//940
printf(“%d\n”,*(a+**a+2)+3);//952
printf(“%d\n”,*(*(a+**a+2)+3));//19
return 0;
}
Correct Answer: A
Question 1 Explanation: 
Check out the step by step program and its output in the comment:
#include
int main()
{
int a[4][5] = { {1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
{16,17,18,19,20}
};
printf(“%d\n”,a); //880 (consider base address = 880)
printf(“%d\n”,*a); //880
printf(“%d\n”,**a); //1
printf(“%d\n”,**a+2); //3
printf(“%d\n”,a+**a+2); //940
printf(“%d\n”,*(a+**a+2));//940
printf(“%d\n”,*(a+**a+2)+3);//952
printf(“%d\n”,*(*(a+**a+2)+3));//19
return 0;
}
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x