0

Output of A code with explanation

What is the output of this program? #include < stdio.h > using namespace std; int main(){ int array[] = {10, 20, 30}; cout << -2[array]; return 0;} a)-20 b)-30 c) garbage value

23rd Feb 2018, 6:37 AM
Hassan Ashiq
Hassan Ashiq - avatar
3 Answers
+ 2
-2[array] =-array[2] =-30
23rd Feb 2018, 6:58 AM
sayan chandra
sayan chandra - avatar
+ 2
welcome brother#) just to ensure... a genral approach.. n[array_name] = (sign of n)array_name[ |n| ]
23rd Feb 2018, 7:26 AM
sayan chandra
sayan chandra - avatar
+ 1
thanksss alottttt
23rd Feb 2018, 7:23 AM
Hassan Ashiq
Hassan Ashiq - avatar