Observe the following C++ code and assume that all desired header files are…

2022

Observe the following C++ code and assume that all desired header files are already included. Identify the possible output from the given options:

  1. A.

    MARKS 80

  2. B.

    ARKS 60

  3. C.

    RKS 70

  4. D.

    KS 90

Attempted by 192 students.

Show answer & explanation

Correct answer: B

Key insight: pointer arithmetic moves pointers to the next element/character; printing a C string followed by an integer prints them immediately adjacent unless you add a separator.

  • P = M sets P to point to M[0] which is 80.

  • P++ increments P to point to M[1] which is 60.

  • S = "MARKS" makes S point to the character 'M'.

  • S++ advances S to point to 'A', so S now refers to the string "ARKS".

  • cout << S << *P; prints the characters of the string "ARKS" followed immediately by the integer 60, producing:

Result: ARKS60

Note: The output is printed without an automatic space between the string and the integer. Among the provided choices, the text "ARKS 60" corresponds to this result as presented in the options.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs