Computer Knowledge

Programming Output Evaluation

1,721 Questions

Programming output evaluation tests the ability to trace code execution in languages like C, Java, and SAS. It focuses on arrays, loops, pointers, and data type conversions. These technical questions are standard in computer knowledge sections for IT officer and bank exams.

Java string bufferC language pointersLoop execution outputsData type conversionsMacro variable evaluation

Programming Output Evaluation Questions

Multiple choice technology programming languages
  1. Compile-Time error

  2. 2.00

  3. %.2

  4. 2.000000

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The format string "%.2" is incomplete - it lacks a type specifier like 'f' for float. In C, this is undefined behavior, but many implementations will simply print the format string literally when it's invalid, resulting in "%.2" as output. This is a common trick question testing knowledge of proper printf format syntax.

Multiple choice technology programming languages
  1. Compile-Time Error

  2. Run-Time Error

  3. 11

  4. None of above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The semicolon ';' is a statement terminator in C, not an operator. Having two semicolons 'int b=6;;' is valid - the second semicolon just creates an empty statement. The program correctly computes c = 5 + 6 = 11 and prints it.

Multiple choice technology programming languages
  1. 2,3

  2. 3,2

  3. 2,2

  4. 3,3

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The nested loops iterate i from 1-3 and j from 1-2. When i==j (i=1,j=1), continue skips to next j. For i=2, j=2: j%3=2 > 1 is false (2 is not > 1), so no break. printf prints '2'. For i=3, j=1: j%3=1 is not > 1, printf prints '3'. Output: 2,3.

Multiple choice technology programming languages
  1. a=5 b=6

  2. a=6 b=5

  3. a=6 b=0

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The swap macro expands to multiple statements separated by semicolons, not a single compound statement. Without braces, only 'temp=a' executes conditionally. Since 5 > 6 is false, the entire block is skipped. temp is static and initialized to 0 by default. printf outputs 'a=6 b=0' because 'a=b; b=temp;' execute unconditionally after the if block.

Multiple choice technology programming languages
  1. Compile-Time error

  2. 5 -6

  3. 5 65530

  4. none of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

val=5 is unsigned int (typically 16-bit range 0-65535). val-11 = 5-11 = -6, which wraps around to 65530 (65535-6+1). The %u format prints unsigned values, so output is 5 65530. Option A is wrong - no compile error. Option B shows signed behavior which %u won't display.

Multiple choice technology programming languages
  1. Compile-Time error

  2. Run-Time Error

  3. 24

  4. Unpredictable

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

*&z is a pointer dereference of z's address, which just gives z. *&z *= *&x * *&y becomes z *= x * y, or z = 2 * 4 * 3 = 24. The *& operators cancel out - & takes address, * dereferences it. This is a pointer trick question testing understanding of address and dereference operators.

Multiple choice technology programming languages
  1. Undefined

  2. 01

  3. 00

  4. 10

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In C++, modifying a variable twice without an intervening sequence point causes undefined behavior. Here c++ both modifies c and yields its original value, but there's no sequence point between the two c evaluations in the cout statement. This violates sequencing rules, making the output undefined rather than predictably 01, 00, or 10.

Multiple choice technology programming languages
  1. Outputs 12

  2. Outputs 10

  3. Outputs the address of v

  4. Undefined

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In main, v is initialized to 10. Its address is passed to afunction. Inside afunction, the local pointer parameter x is reassigned to point to a newly allocated memory address, leaving the original variable v in main completely unmodified. Thus, v remains 10.