Discussion
Predict the output of below code:
#include <stdio.h>
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}
Answer: C
Correct answer: Compile time Error
ary[0][0] has type int[4] - a whole row of four ints, not a single element. An array is not a modifiable lvalue, so it cannot be assigned to, and the type on the right, int *, does not match in any case. The compiler rejects the assignment; ary[0][0][0] = j; would be the sensible statement.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development