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 program will find the sum of digits.

  2. The program will find the number of digits.

  3. Invalid

  4. The program will run infinite times.

  5. There is a error in the program.

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

This option is correct.

Multiple choice
  1. a string

  2. a char

  3. an int

  4. all of the above

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

The ostream.put() method in C++ is specifically designed to write a single character to the output stream. It takes a char as parameter and writes it to the stream.

Multiple choice
  1. Num=12

  2. Num=13

  3. Garbage value

  4. Error in the program

  5. Blank screen (no output)

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

There is an error in the program. We have declared the num variable as constant by const keyword. So, in this program we cannot modify its value. The compiler will give an error that “ cannot modify the constant object” or “[error] increment of read only variable num”. So, this option is true.

Multiple choice
  1. u=1

  2. u=2

  3. u=65535

  4. error in the program

  5. None of these

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

This is the correct answer. Unsigned integer has a maximum value range 0-65535. So, this is the maximum value. So, u=65535 will be printed. After reaching the last range compiler will start from beginning like for 65636, output will be 1, and for 65537, output will be 2. So, this option is true.

Multiple choice

What is the ASCII value of ESC character?

 #include<stdio.h>

#include<conio.h>

using namespace std;

class first

{

      int b;

      public:

             first()

             {

                    b=10;

                    }

                    void display()

                    {

                         cout<<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n b=<

                         }

                         };

                         class second

                         {

                               int d;

                               public:

                                      second()

                                      { d=20;

                                      }

                                      void display()

                                      {

                                            cout<<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n d=<

                                            }

                                            };

                                            int main()

                                            {

                                                first f,*p;

                                                second s,*i;

                                                p=&f;

                                                p->display();

                                                i=&s;

                                                p->display();

                                                getch();

                                                }

  1. 27

  2. 28

  3. 29

  4. 30

  5. None of these

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

This value is correct answer for the question. The ASCII value of ESC character is 27. This is a standard value known as AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE. This can be seen in any C language book. <strong> <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } --> </strong>

Multiple choice
  1. 1,2,_ _ _ 10

  2. an infinite loop

  3. 1,2,3 _ _ _ 9

  4. error in code

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

The while loop condition is followed by a semicolon, creating an empty loop body. Since icount is initialized to 1 and never incremented within the loop, the condition (icount < 10) remains true forever. The program enters an infinite loop and never reaches the printf statement.

Multiple choice
  1. ONE AND HALF

  2. TWO

  3. FOUR

  4. error in code

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

Switch statement case labels must be integer constant expressions, not floating-point values. The value 1.5 is a floating-point literal, which violates C syntax rules for case labels. This causes a compilation error.

Multiple choice
  1. 1 2 3 4 5

  2. 2000 2002 2004 2006 2008

  3. 10 20 30 40 50

  4. error in code

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

The expression *(b+i) is pointer arithmetic equivalent to b[i]. As i iterates from 0 to 4, this accesses each element of array b sequentially. The array contains 10, 20, 30, 40, 50, which are printed in order.