arrow
arrow
arrow
What will be the output of the code snippet?
Question



What will be the output of the code snippet?

A.

10

B.

15

C.

5

D.

Compilation Error

E.

None of the above

Correct option is B


1. Variable Initialization: x is declared and initialized to 10.
2. Pointer Initialization: a is declared as a pointer to an integer and initialized to the address of x. Now, *a points to x.
3. Dereferencing and Modification: *a = *a + 5; This statement adds 5 to the value pointed to by a, which is x. So: x = x + 5 = 15.
4. Output: printf("%d\n", *a); prints the value of x, which is now 15.
Key Points:
1. Dereferencing a pointer (*a) accesses the value stored at the memory address it points to.
2. Modifying *a directly updates the value of x since a points to the memory location of x.
Knowledge Booster:
· Pointer Basics: A pointer stores the address of a variable, and dereferencing a pointer (*) allows access to the value stored at that address.
· Use Case: Pointers are crucial for dynamic memory management, function arguments (pass by reference), and data structures like linked lists.

Free Tests

Free
Must Attempt
Video Solutions

SBI Clerk Mains 2026 Full Mock Test-01

languageIcon English
  • pdpQsnIcon190 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon160 Mins
languageIcon English
Free
Must Attempt

SBI Clerk Mains MBT (29th October 2026 S1)- Based on Backlog Vacancies

languageIcon English
  • pdpQsnIcon190 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon160 Mins
languageIcon English
Free
Must Attempt

SBI Clerk Mains 2026 : Reasoning Section Test - 01

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon60 Marks
  • timerIcon45 Mins
languageIcon English
test-prime-package

Access ‘IBPS RRB SO IT Officer (Scale-II)’ Mock Tests with

  • 1.5 Lakhs+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
592k+ students have already unlocked exclusive benefits with Test Prime!
test-prime-package

Access ‘IBPS RRB SO IT Officer (Scale-II)’ Mock Tests with

  • 1.5 Lakhs+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
592k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow