VOOZH about

URL: https://www.geeksforgeeks.org/c/output-of-c-programs-set-15/

⇱ Output of C Programs | Set 15 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C Programs | Set 15

Last Updated : 16 Sep, 2024

Predict the output of below C programs. 
Question 1

Output: 3 6

Explanation: ++ has precedence over + and operates right to left. Hence rightmost ++a gives a=2 and the ++a left of it gives a=3. Now, while evaluating, b=3+3. As after the second ++a, we have a=3. Hence b=3+3=6 and a=3. Hence the output.
Question 2

Output: 6 
&a is address of the whole array a[]. If we add 1 to &a, we get "base address of a[] + sizeof(a)". And this value is typecasted to int *. So ptr - 1 points to last element of a[] 
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.

Comment
Article Tags:
Article Tags: