Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 49

What is the expected behavior of the following code?

    Correct Answer: C

    The code initializes a string '123' and a variable 'dummy' set to 0. It then iterates over the reversed string, converts each character to an integer, and adds it to 'dummy'. The reversed string is '321', so the code performs the following operations: dummy += 3 (dummy is now 3), dummy += 2 (dummy is now 5), dummy += 1 (dummy is now 6). Finally, it prints the value of 'dummy', which is 6. Therefore, the correct answer is output 6.

Discussion
DKAT2023Option: C

C is correct