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. GATE2011

  2. E2011

  3. 2011

  4. 011

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

The pointer p points to 'G' (index 0). p[3] = 'E' (ASCII 69) and p[1] = 'A' (ASCII 65). So p[3] - p[1] = 69 - 65 = 4. Therefore p + 4 points to index 4, which is '2'. printf(%s, p+4) prints from '2' onward: '2011'. The key is pointer arithmetic with character ASCII values.

Multiple choice
  1. No choice

  2. Choice A

  3. Choice A, Choice B No choice

  4. Program gives no output as it is erroneous

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

Since there is no ‘break’ statement, the program executes all the subsequent case statements after printing “choice A”

Multiple choice
  1. 3 1 4 1 4 2

  2. 4 2 6 1 6 1

  3. 4 2 6 2 2 0

  4. 4 2 4 2 2 0

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

Static local variables: Scope is limited to function/block but life time is entire program. Automatic local variables: Storage allocated on function entry and automatically deleted or freed when the function is exited. Register variables: Same as automatic variables except that the register variables will not have addresses. Hence, may not take the address of a register variable.

Multiple choice
  1. S1

  2. S2 and S3

  3. S2 and S4

  4. S2 and S5

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

Multiple choice
  1. {mm $\ge$ n, ($\ge$i)[m=i!] }
  2. {mm $\ge$ n, ($\exists $i)[m=i2]}
  3. {mm $\le $ n, m is prime}
  4. { }

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

 

Multiple choice
  1. 10, 3

  2. 31, 3

  3. 27, 7

  4. None of the above

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

Here, we are passing the variables by call by reference. This means that the changes that we will make in the parameter would be reflected in the passed argument. Here, the first variable passed in the function func1 (i.e., y) points to the address of the variable x. Similarly, the second variable passed in the function func1 (i.e., x) points to the address of the variable y and the third variable passed in the function func1 (i.e., x) points to the address of the variable z.

So, we have y = y + 4 ⇒ y = 10 + 4 = 14 and z = x + y + z ⇒ z = 14 + 14 + 3 = 31 z will be returned to x. So, x = 31 and y will remain 3.