What will be the output of the following code if executed: printf("%d%d%d\n", a,c,b);?

Disable ads (and more) with a membership for a one time $4.99 payment

Study for the University of Central Florida (UCF) EGN3211 Exam. Prepare with comprehensive material, flashcards, and multiple choice questions. Enhance your understanding and excel in your exam!

To understand the output of the code snippet printf("%d%d%d\n", a, c, b);, we need to analyze the order of the variables being printed and their corresponding values.

In C programming, when using printf, the variables are evaluated in the order they are listed in the function call. Therefore, if we have three integer variables a, b, and c with the respective values assigned to them as follows:

  • a = 1
  • b = 2
  • c = 3

When executing printf("%d%d%d\n", a, c, b);, the values for the variables will be printed in the sequence given:

  1. The first %d prints the value of a, which is 1.
  2. The second %d prints the value of c, which is 3.
  3. The third %d prints the value of b, which is 2.

Hence, the output will be 132, as the values are printed in the order of a (1), c (3), and b (2). This confirms that option B is indeed the correct answer.