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

  2. 28.055555

  3. 28.655555

  4. 22.655555

  5. 28.355555

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

The program will evaluate the series as X + X2 / 2! + X4 / 4! + X6 / 6! + .................... Xn / n! So, putting values of x and y in program, the result will be 28.355555. Hence, option (5) is correct.

Multiple choice
  1. answer = 9

  2. answer = 16

  3. answer = 25

  4. garbage value

  5. none of these

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

The value is returned by input 5. It is subtracted as 1 - 5 + 1 = 2 – 5 = (- 3)2 = 9; Pow(3,2) = 32 = 9 Hence, option (1) is correct.

Multiple choice
  1. k = 0, l = 2, a = 0.00000, b = 2.00000

  2. ERROR:-cannot convert an integer to float

  3. k = 0, l = 2, a = garbage value, b = garbage value

  4. k = 0, l = 2, a = 0, b = 2

  5. None of these

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

 Output will be k = 0, l = 2, a = 0.0000 and b = 2.0000 Hence, option 1 correct.

Multiple choice
  1. c=1

  2. c=0

  3. c=-1

  4. garbage value

  5. error in the program

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

This program will first compare a > b, which is false as 9 < 10. So result will be 0. Then it will compare b > a (10 > 9) which is true. So result will be 1.So it will become as c=(0 || 1). So binary of 0 OR binary of 1. The result will be 1 0 0 0 0 0 1____0 0 1. So, this is the correct answer.

Multiple choice
  1. v=-1

  2. v=4294967295

  3. v=4294967296

  4. v=0

  5. error in the program

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

Unsigned data types don’t have negative values. They have range from 0 to 4294967295. So, if negative value is given to any variable, it will count from its last value,  which is 4294967295. So, this is the correct answer. If we give v = -2, the result will be 4294967294. So, it will keep decrementing values.

Multiple choice
  1. 9

  2. 10

  3. 11

  4. 12

  5. None of these

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

This program will run until d becomes greater than 9. As we can see the value of c (c=1) is greater than d (d=0). So c will always be one greater than the value of d, because both are incrementing at the same time. So, when d = 0 (d <= 9), condition becomes true. So when d becomes 1, c becomes 2, and when d is 9 (d <= 9), which is again true, then d becomes 10 and c becomes 11, which is one greater than d. The program runs 10 times. So final value of c is 11.

Multiple choice
  1. a=24, b=24

  2. a=12, b=24

  3. We cannot perform addition in pointers(*pt+5)

  4. None of these

  5. Error in the program

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

First the value of c=3 is assigned to pt by the statement pt=&c. So in a1=3(c+5), it becomes a1=3*(3+5). So result is a1=24. After that we know that pt is equal to the value of c,  which is 3. So, a2=3(pt+5) becomes a2=3(3+5). The result is again 24. So, both ai and a2 are 24. Therefore, this is the correct option.

Multiple choice
  1. GoodBoy

  2. Good

  3. Boy

  4. None of these

  5. Error in the program

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

The program will switch the statements with the value x=’G’. If (x==’B’), then if part will be executed. But x is equal to ‘G’. So, else part will be executed. Now the question arises that why default is executed. As we can see that else part contains the default part. Therefore, default is also executed with case ‘G’. So, the result is GoodBoy.

Multiple choice
  1. a=5, b=15

  2. a=15, b=15

  3. a=5, b=5

  4. a=15, b=5

  5. Error in the program

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

In this program first we assign the value of a to b by the statement (b=&a), which means b contains value of a. Now after that **c contains the value of b (c=&b), which means value of b is in **c. Now we assign **c=15, which means **c=15 and b is also become 15 as (c=&b). Now as (*b=*c), it makes b=15. Now as we know (*b=&a), so value of a also becomes 15. In this way both a and b will be printed as 15.

Multiple choice
  1. Invalid number

  2. Result is 425

  3. Result is 625

  4. Result is 525

  5. Error in the program

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

The answer would be 425. The program will firstly find 25%10 which comes out to be 5. So if(d==5) becomes true, then 25/10=2 will be stored in s. And s*s++ will give the result 6 and d*d gives the result 25. So, 625 will get printed.

Multiple choice
  1. Executable code

  2. Bytecode

  3. Bitcode

  4. Assembly language code

  5. None of these

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

The output of compiler is bytecode, which is a platform independent file.

Multiple choice
  1. WWEWELWELCWELCOWELCOMWELCOM

  2. WELCOMEWELCOMWELCOWELCWELWEW

  3. W WE WEL WELC WELCO WELCOM WELCOME

  4. WELCOME

  5. None of the above

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

A is an array having value “WELCOME “. So at 0th position W is present.i=0a.substring(0,0) =>Wi=1a.substring(0,1) =>WEi=2a.substring(0,2) =>WELTherefore option ‘1’ is correct answer.

Multiple choice
  1. Separates digits and reverses the number

  2. Reverses the number

  3. Addition of digits of the given input number

  4. All of the above

  5. None of the above

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

The above code fragment separates the digits and does addition of digits of the given number 4325. The output of the given program code is 14.