7 votes 7 votes What is the output of the following program? #include<stdio.h> int main() { int array[]={10, 20, 30, 40}; printf(“%d”, -2[array]); return 0; } $-60$ $-30$ $60$ Garbage value Programming in C programming-in-c output programming pointers + – Parshu gate asked Nov 20, 2017 • edited Aug 8, 2021 by soujanyareddy13 Parshu gate 797 views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply Anjan commented Nov 20, 2017 reply Follow Share -2[a] = a[-2] = Garbage value 0 votes 0 votes nikkey123 commented Nov 20, 2017 reply Follow Share what is the answer ? 0 votes 0 votes Anjan commented Nov 20, 2017 reply Follow Share I got D as Ans 0 votes 0 votes Parshu gate commented Nov 20, 2017 reply Follow Share It is -(array[2]) not array[-2] 0 votes 0 votes joshi_nitish commented Nov 20, 2017 reply Follow Share @Anjan -2[a], here [ ] has high priority over uniary minus(-), so expression will look like (-(2[a])) your's answer would be correct if it would be (-2)[a] 4 votes 4 votes Anjan commented Nov 20, 2017 reply Follow Share That clear now :) thanks btw 0 votes 0 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes arr[i] is equal to i[arr] is also equal to *(arr+i) so answer should be -30 Red_devil answered Nov 20, 2017 • selected Nov 20, 2017 by Parshu gate Red_devil comment Share Follow See all 0 reply Please log in or register to add a comment.
7 votes 7 votes ......... abhishekmehta4u answered Mar 12, 2018 abhishekmehta4u comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes -30 is the answer Ankish Gupta 3 answered Mar 12, 2018 Ankish Gupta 3 comment Share Follow See all 0 reply Please log in or register to add a comment.