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. The C standard says that dereferencing a null pointer causes undefined behavior. This may explain why printf() apparently fails.

  2. If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs.

  3. printf() always buffers output until a new line character appears in the buffer. Since no newline was present in the format string, nothing is printed.

  4. There is insufficient information to determine why the output fails to appear. A broader context is required.

  5. printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.

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

Standard output is typically line-buffered or fully buffered. If the program crashes before a newline is encountered or the buffer is flushed, the output may not appear.

Multiple choice
  1. 4

  2. 5

  3. 6

  4. 7

  5. 8

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

The array initialization contains 6 strings separated by commas: 'Sleepy', 'Dopey Doc', 'Happy', 'Grumpy Sneezy', 'Bashful'. Wait, the list is: Sleepy, Dopey Doc, Happy, Grumpy Sneezy, Bashful. That is 5 elements.

Multiple choice
  1. ab

  2. abcdef

  3. abcdef, followed by garbage

  4. none of above

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

The printf function takes a format string as the first argument. Subsequent arguments are ignored if there are no format specifiers in the string.