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. Infinite loop

  2. Compilation error

  3. Runtime error

  4. 1

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

The basic thing that we need to remember in C is that zero means false. Now, the code inside for loop as condition is checked. Variable i is zero since we are using post-increment operator. Hence, loop is terminated and after that 1 is printed which is the final value of i. Therefore, this is the correct answer. 

Multiple choice
  1. 2 1 15

  2. 1 2 5

  3. 3 2 15

  4. 2 2 2

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

Initially, a[1] is 1. The line i = ++a[1] increments a[1] to 2 and sets i to 2. Then j = a[1]++ sets j to 2 and increments a[1] to 3. Finally, m = a[i++] assigns a[2](which is 15) to m and increments i to 3, resulting in 3 2 15.

Multiple choice
  1. 10 10

  2. 10 1

  3. 1 10

  4. None of these

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

DIM1 is a macro that calculates the array size correctly (10) because the array name in that scope represents the whole array. In DIM2, the array decays into a pointer when passed as an argument, so sizeof(array) returns the size of a pointer, resulting in 1.