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
  1. 1,2,_ _ _ 10

  2. an infinite loop

  3. 1,2,3 _ _ _ 9

  4. error in code

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

The while loop condition is followed by a semicolon, creating an empty loop body. Since icount is initialized to 1 and never incremented within the loop, the condition (icount < 10) remains true forever. The program enters an infinite loop and never reaches the printf statement.

Multiple choice
  1. ONE AND HALF

  2. TWO

  3. FOUR

  4. error in code

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

Switch statement case labels must be integer constant expressions, not floating-point values. The value 1.5 is a floating-point literal, which violates C syntax rules for case labels. This causes a compilation error.

Multiple choice
  1. 1 2 3 4 5

  2. 2000 2002 2004 2006 2008

  3. 10 20 30 40 50

  4. error in code

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

The expression *(b+i) is pointer arithmetic equivalent to b[i]. As i iterates from 0 to 4, this accesses each element of array b sequentially. The array contains 10, 20, 30, 40, 50, which are printed in order.

Multiple choice
  1. Hello

  2. lo

  3. llo

  4. Error

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

The function fun() increments the pointer by 3 (ptr+=3), advancing it from 'Hello' to point at 'lo'. This pointer is returned to main() where it's printed. String 'Hello' has indices 0-4 for H,e,l,l,o, so +3 points to index 3 which is 'l', making the string 'lo'.

Multiple choice
  1. 22 10 11 13

  2. 22 11 11 11

  3. 22 10 11 13

  4. 22 13 13 13

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

In printf, arguments are evaluated right-to-left. Starting with a=10: a++ makes a=11 (but evaluates to 10 in first operation), then ++a makes a=12 (evaluates to 12). So b=10+12=22. For printf: ++a makes a=13, then a is 13, then a++ evaluates to 13 (a becomes 14), and b is 22. Output: 22 13 13 13.

Multiple choice
  1. System Hangs

  2. 100 100

  3. 0 100

  4. 1 100

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

The outer for loop has no condition (empty middle clause), so it's infinite: for(i=0;;i++). The inner loop is also infinite: for(j=0;;j++). The break only exits the inner loop when j>100, but then the inner loop restarts with j=0. This continues forever, causing the system to hang.