Computer Knowledge

Programming Output Evaluation

1,721 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. Prints 1 to n

  2. Prints 1 to n-1

  3. Prints n

  4. Infinite loop

  5. Compilation error

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

error: address of register variable ‘n’ requested The program will not print any output because there is an error in the program. We cannot refer to the address of a register variable because it is not stored in the memory but on the registers inside the CPU. Only variable stores in the memory have an address.S o there will be an error in the program. Hence this option is correct.

Multiple choice
  1. Infinite loop

  2. Hello World is printed 65535 times

  3. Error: Calling main() function is not allowed

  4. Error: Stack overflow

  5. None of these

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

The program will run for some time, and after that it will give an error. The reason is :-A stack(call stack) is used to store information about the active subroutines of a computer program. So whenever control transfer from one function(subroutine) to another function, return address and other parameter are stored on stack.In above program main is calling itself repeatedly, it creates an infinite loop. Each call pushes return address and other parameters to call stack and it continues till stack is full. When stack is full it terminates with error : Segmentation fault (core dumped).So this is the correct answer.

Multiple choice
  1. 10, 20

  2. 10, 10

  3. 20, 10

  4. 20, 20

  5. Error in the program

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

In above program, function is called by value. In call by value parameter's copies are made. Initially at Line 6 from where swap function is called,  a = 10, b=20.    a --> | 10 |   b-->| 20 |           Now, control goes to Line 9 and values of a,b are copied to x,y. Now, x=10, y=20 and a = 10, b= 20  a --> | 10 |   b-->| 20 |  x --> | 10 |   y-->| 20 |   After these values of x and y are swapped, x=20, y=10 but still values of a and b are 10 and 20.     a --> | 10 |   b-->| 20 |  x --> | 20 |   y-->| 10 |   So whatever changes we have done in swap function is on x and y, which is a separate copy of a and b.  So this is the correct answer. 

Multiple choice
  1. Compiles with no warning and error messages

  2. Compiles with warning: conflicting types for dispalyOut

  3. Does not compile, gives error : dispalyOut not declared

  4. Compiles but throws error while linking

  5. Hi I am Robot

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

This is the correct option  because in this program we are calling the function displayout(), but we haven’t given its return type. So in the compile time, the compiler will throw an error that “Displayout was not declared in this scope”.

Multiple choice
  1. Hello from main, inside, and deepinside function

  2. Hello from main, inside

  3. Hello from main, and deepinside function, inside

  4. Error in the program

  5. None of the above

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

There will be a compile time error in the program. Definition of a function is not allowed inside body of any other function in Standard C.If you are using gcc compiler, then program compiles.So this is the correct answer.  

Multiple choice
  1. The result comes out to be 0111.

  2. The result comes out to be 1111.

  3. The result comes out to be 1000.

  4. The result comes out to be 0110.

  5. Error in the program

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

Binary of 7 is  0111. Binary of 15 is 1111. So ORing them result comes out to be 1111.