hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    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

    RBI Assistant Pre 2026 Full Mock Test -01

    languageIcon English
    • pdpQsnIcon100 Questions
    • pdpsheetsIcon100 Marks
    • timerIcon60 Mins
    languageIcon English
    Free
    Must Attempt
    Video Solutions

    RBI Asst Prelims 2026 : Reasoning Section Test 01

    languageIcon English
    • pdpQsnIcon35 Questions
    • pdpsheetsIcon35 Marks
    • timerIcon20 Mins
    languageIcon English
    Free
    Must Attempt
    Video Solutions

    RBI Office Attendant 2026 Full Mock Test - 01

    languageIcon English
    • pdpQsnIcon120 Questions
    • pdpsheetsIcon120 Marks
    • timerIcon90 Mins
    languageIcon English
    test-prime-package

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

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