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 technology programming languages
  1. CompilationFails

  2. Will Throw RunTime Error But Code will get Compiled

  3. Throws Linker Error

  4. All the above statements are invalid

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

sizeof(void) is invalid in C and C++ - void is an incomplete type with no defined size. The malloc call will fail to compile because you cannot determine the size of void.

Multiple choice technology programming languages
  1. 5,4

  2. -4,4

  3. -5,4

  4. -4,5

  5. Compilation Error

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

The post-decrement operator a-- evaluates to the current value of a (which is 5) before decrementing a to 4. Therefore, num is assigned -5. The final values printed for num and a are -5 and 4, matching the marked choice.

Multiple choice technology programming languages
  1. 10

  2. 20

  3. Compilation Error

  4. RuntimeError

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

The pointer z stores the address of x. Initially x=10, then x=20 overwrites it. When *z=10 executes, it dereferences the pointer and modifies the value at address z, which is x. This changes x back to 10. The final value of x is 10.

Multiple choice technology programming languages
  1. CompilationFails

  2. Will Throw RunTime Error But Code will get Compiled

  3. Throws Linker Error

  4. All the above statements are invalid

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

The code uses sizeof(void) which is invalid in C/C++ - you cannot determine the size of void type. This causes a compilation error. Void pointers exist, but void itself is an incomplete type with no defined size. Additionally, incrementing a void pointer (ptr++) requires knowing the size of the pointed-to type, which is impossible for void* without a cast.

Multiple choice technology programming languages
  1. 5,4

  2. -4,4

  3. -5,4

  4. -4,5

  5. Compilation Error

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

The post-decrement operator a-- returns the current value (5) before decrementing a to 4. Unary minus is then applied to the returned value (5), giving -5. So num = -5, a = 4, output is "-5 4".

Multiple choice technology programming languages
  1. Prints "True"

  2. Prints nothing

  3. Prints false

  4. Error in if condition

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

The code uses assignment (=) instead of equality (==) in the if condition, so b becomes true and the condition passes. This is a common bug - the if statement evaluates the result of the assignment, which is the assigned value (true), causing 'True' to be printed.