edited by
814 views
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;

}
  1. $-60$
  2. $-30$
  3. $60$
  4. Garbage value
edited by

3 Answers

Best answer
3 votes
3 votes
arr[i] is equal to i[arr] is also equal to *(arr+i)

so answer should be -30
selected by

Related questions

1.5k
views
1 answers
3 votes
Parshu gate asked Nov 13, 2017
1,461 views
main( ){int n[3][3] = {2, 4, 3,6, 8, 5,3, 5, 1} ;printf ( "\n%d %d %d", *n, n[3][3], n ) ;}
1.2k
views
1 answers
1 votes
kaveeshnyk asked May 7, 2019
1,156 views
#include<stdio.h int main(){ int (*a)[5]; int arr[5][5]={ {10,65,300,400,500}, {100,20,3000,40,5000} }; a = arr; ++a ; char *ptr = (char*)*a...
1.7k
views
0 answers
1 votes
Ashish Roy 1 asked Mar 16, 2019
1,740 views
In the above 4 Statements which would print 123 as output ? Explain also.
456
views
0 answers
1 votes
Akshay Nair asked Jan 29, 2018
456 views
What is the output of the following program?void main(){printf("%d",5%2);printf("%d",-5%2);printf("%d",5%-2);printf("%d",-5%-2);printf("%d",2%5);}A) 1,-1 -1 1 0B)1 -1 1 -...