Skip to content
Related Articles
Open in App
Not now

Related Articles

QA – Placement Quizzes | SP Contest 2 | Question 9

Improve Article
Save Article
  • Last Updated : 18 Jul, 2018
Improve Article
Save Article

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




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


(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
Related Articles

Start Your Coding Journey Now!