Programming Quiz

Results

#1 The prices of two products x and y are 125 and 110 respectively. But the prices of x and y are incorrectly entered as 110 and 125 respectively by the programmer while calculating the profit and loss from both the products. How can the programmer correct the values of x and y?

#2 What is the output of the following code segment?

#3 What will be the output of each of the code fragments?

#4 Consider the following code segment and determine the value of the function call min(max(a,b), max(x,y)). If a = 100, b = 0, x = 67, y = 33.

#5 Which of the following correctly uses an assignment operator with the values m and n?

#6 What will be the value of count after the execution of the following code segment?

#7 What is the value of sum after executing the following code?

#8 Given the function “fun”, what will be the output of fun (16) ?

#9 Consider the following code segment. What will be printed as a result when the code is executed?

#10 [8, 1, 10, 6, 4, 2] Assume that these are the elements of a stack ‘S’ such that 2 is the top most element and 8 is the element at the bottom of the stack. Note that, push(), pop(), peek() are the methods used with the stack; push(int x) inserts an integer x onto the top of the stack; int pop() removes the integer at the top of the stack and returns that integer; int peek() returns the integer at the top of the stack without removing it from the stack. How does the Stack look like after executing the following code segment?

finish