Computer Knowledge

Programming Output Evaluation

1,953 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 5 9

  2. 4 8 12

  3. 1 4 7 10

  4. 1 3 6 9 12

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

The code has multiple errors: it declares 'num' but uses 'z' in the comparison, and uses HTML entities (<) instead of operators. If we assume it meant to use 'num' and proper '<' operators, each iteration finds the minimum value in a row. Row 0 minimum is 1, row 1 minimum is 5, row 2 minimum is 9, so output would be '1 5 9'.

Multiple choice
  1. for(i=0;i<80;++i)

  2. for(i=0;i<=60;i++)

  3. for(i=1;i<60;i++)

  4. for(i=0;i<60;++i)

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

To read exactly 60 characters, the loop must run 60 times with index starting at 0 and going up to (but not including) 60. The condition 'i<60' achieves this - it runs for i=0,1,2,...,59, which is exactly 60 iterations. This stores characters at indices 0 through 59.

Multiple choice
  1. Winter Autumn

  2. Autumn

  3. Summer Autumn

  4. Winter

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

Tracing the nested conditions with p=10, q=20, r=30: First if (p>10)||(q<30) evaluates to (false)||(false) = false, so we skip to the final cout statement and print 'Autumn'. The inner if-else blocks are never executed.

Multiple choice
  1. class stars

  2. class moon

  3. class sun

  4. none of the above

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

This code has a compilation error due to diamond inheritance ambiguity. Class stars inherits from both sun and moon, each having a result() method. Calling s.result() is ambiguous - the compiler cannot determine which result() to use. This requires scope resolution (s.sun::result() or s.moon::result()) or virtual inheritance.

Multiple choice
  1. class stars

  2. class moon

  3. class sun

  4. none of the above

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

This code has a compilation error due to diamond inheritance ambiguity. Class stars inherits from both sun and moon, each having a result() method. Calling s.result() is ambiguous - the compiler cannot determine which result() to use. This requires scope resolution (s.sun::result() or s.moon::result()) or virtual inheritance.