QA – Placement Quizzes | SP Contest 2 | Question 9

What will be the output of the below C++ program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<iostream>
using namespace std;
  
int main()
{
    int a[] = {10,20,30,40,50};
      
    cout<<(*(&a+1)-a);
      
    return 0;
}

chevron_right


(A) 10
(B) 0x7ffc7185f754
(C) 50
(D) 5


Answer: (D)

Explanation: Refer to method 2 of this post: https://www.geeksforgeeks.org/how-to-find-size-of-array-in-cc-without-using-sizeof-operator/

Quiz of this Question
Please comment below if you find anything wrong in the above post



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.