Ques 91 : Choose the correct answer | ||||
What does the following function do?
function operation (int a, int b) |
||||
Option 1 : Always returns the first parameter | Option 2 : Returns the min of (a,b) | Option 3 : Returns the max of (a,b) | Option 4 : Loops forever | |
|
||||
Ques 92 : Choose the correct answer | ||||
function g(int n) { if (n > 0) return 1; else return -1; }function f(int a, int b) { if (a > b) return g(b-a); if (a < b) return g(a-b); return 0; }If f(a,b) is called, what is returned? |
||||
Option 1 : Always -1 | Option 2 : 1 if a > b, -1 if a < b, 0 otherwise | Option 3 : -1 if a > b, 1 if a < b, 0 otherwise | Option 4 : 0 if a equals b, -1 otherwise | |
|
||||
Ques 93 : Choose the correct answer | ||||
function g(int n) { if (n > 0) return 1; else return -1; }function f(int a, int b) { if (a > b) return g(a-b); if (a < b) return g(b-a); return 0; }If f(a,b) is called, what is returned? |
||||
Option 1 : 1 if a > b, -1 if a < b, 0 otherwise | Option 2 : Always +1 | Option 3 : 0 if a equals b, +1 otherwise | Option 4 : -1 if a > b, 1 if a < b, 0 otherwise | |
|
||||
Ques 94 : Choose the correct answer | ||||
function g(int n) { if (n > 0) return 1; else return -1; }function f(int a, int b) { if (a > b) return g(a-b); if (a < b) return g(-b+a); return 0; }If f(a,b) is called, what is returned? |
||||
Option 1 : Always +1 | Option 2 : 1 if a > b, -1 if a < b, 0 otherwise | Option 3 : -1 if a > b, 1 if a < b, 0 otherwise | Option 4 : 0 if a equals b, -1 otherwise | |
|
||||
Ques 95 : Choose the correct answer | ||||
function g(int n) { if (n > 0) return 1; else return -1; }function f(int a, int b) { if (a > b) return g(b-a); if (a < b) return g(-a+b); return 0; }If f(a,b) is called, what is returned? |
||||
Option 1 : Always +1 | Option 2 : -1 if a > b, 1 if a < b, 0 otherwise | Option 3 : 1 if a > b, -1 if a < b, 0 otherwise | Option 4 : 0 if a equals b, -1 otherwise | |
|
||||
Ques 96 : Choose the correct answer | ||||
Consider the following code:
for i= m to n increment 2 Assuming m < n and exactly one of (m,n) is even, how many times will Hello be printed? |
||||
Option 1 : (n – m + 1)/2 | Option 2 : 1 + (n – m)/2 | Option 3 : 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd | Option 4 : (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd | |
|
||||
Ques 97 : Choose the correct answer | ||||
Consider the following code:
for i= m to n increment 2 Assuming m < n and (m,n) are either both even or both odd, How many times will Hello be printed? |
||||
Option 1 : (n – m + 1)/2 | Option 2 : 1 + (n – m)/2 | Option 3 : 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd | Option 4 : (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd | |
|
||||
Ques 98 : Choose the correct answer | ||||
Assuming n > 2, What value does the following function compute for odd n?
function f (int n) |
||||
Option 1 : 1 + 2 + 3 + 4 + … + n | Option 2 : 1 + 3 + 5 + 7 + … + n | Option 3 : n/2 + (1 + 3 + 5 + 7 + … + n) | Option 4 : 1 + (1 + 3 + 5 + 7 + … + n) | |
|
||||
Ques 99 : Choose the correct answer | ||||
Assuming n > 2, What value does the following function compute for even n?
int f (int n) |
||||
Option 1 : 1 + 2 + 3 + 4 + … + n | Option 2 : 1 + (2 + 4 + 6 + 8 + … + n) | Option 3 : 1 + n/2 + (4 + 6 + 8 + … + n) | Option 4 : 2 + 4 + 6 + 8 + … + n | |
|
||||
Ques 100 : Choose the correct answer | ||||
The for loop is equivalent to a while loop when | ||||
Option 1 : There is no initialization expression | Option 2 : There is no increment expression | Option 3 : A and B combined are true | Option 4 : It is never equivalent | |
|
||||
Ques 101 : Choose the correct answer | ||||
Consider the statement while (a < 10.0) { a = a*a }Assuming a is positive, for what value of a will this code statement result in an infinite loop? |
||||
Option 1 : a < 1.0 | Option 2 : a < sqrt(10) | Option 3 : a > sqrt(10) | Option 4 : a = 0 | |
|
||||
Ques 102 : Choose the correct answer | ||||
int area(double radius) { return PI*radius*radius; }Which of the following is always true about the function area? |
||||
Option 1 : It returns the area of a circle within the limits of double precision. | Option 2 : It returns the area of a circle within the limits of the constant PI. | Option 3 : It returns the area of a circle within the limits of precision of double, or the constant PI, whichever is lower. | Option 4 : None of the above. | |
|
||||
Ques 103 : Choose the correct answer | ||||
What does this function compute for positive n?
function f(int n) |
||||
Option 1 : 1 + n | Option 2 : 1 + 2 + 3 + … + n | Option 3 : 1 + n, if n > 1, 1 otherwise | Option 4 : None of the above | |
|
||||
Ques 104 : Choose the correct answer | ||||
Which of these is not a data type? | ||||
Option 1 : integer | Option 2 : character | Option 3 : boolean | Option 4 : array | |
|
||||
Ques 105 : Choose the correct answer | ||||
The construct “if (condition) then A else B” is for which of the following purposes? | ||||
Option 1 : Decision-Making | Option 2 : Iteration | Option 3 : Recursion | Option 4 : Object Oriented Programming | |
|
||||
Ques 106 : Choose the correct answer | ||||
In a sequential programming language, code statements are executed in which order? | ||||
Option 1 : All are executed simultaneously | Option 2 : From top to bottom | Option 3 : From bottom to top | Option 4 : None of these | |
|
||||
Ques 107 : Choose the correct answer | ||||
A for-loop is used for which of the following purposes? | ||||
Option 1 : Decision-Making | Option 2 : Iteration | Option 3 : Recursion | Option 4 : None of these | |
|
||||
Ques 108 : Choose the correct answer | ||||
There are two loops which are nested. This implies which one of the following? | ||||
Option 1 : Two loop, one after the other | Option 2 : Two loops, one inside the others | Option 3 : One loop with two different iteration counts | Option 4 : Two loops with the same iteration count | |
|
||||
Ques 109 : Choose the correct answer | ||||
How will 47 be stored as an unsigned 8-bit binary number? | ||||
Option 1 : 10111101 | Option 2 : 00101111 | Option 3 : 10111000 | Option 4 : 00101101 | |
|
||||
Ques 110 : Choose the correct answer | ||||
An integer X is saved as an unsigned 8-bit number, 00001011.What is X? | ||||
Option 1 : 22 | Option 2 : 11 | Option 3 : 10 | Option 4 : None of these | |
|
||||
Ques 111 : Choose the correct answer | ||||
A variable cannot be used… | ||||
Option 1 : Before it is declared | Option 2 : After it is declared | Option 3 : In the function it is declared in | Option 4 : Can always be used | |
|
||||
Ques 112 : Choose the correct answer | ||||
What is implied by the argument of a function? | ||||
Option 1 : The variables passed to it when it is called | Option 2 : The value it returns on execution | Option 3 : The execution code inside it | Option 4 : Its return type | |
|
||||
Ques 113 : Choose the correct answer | ||||
Which of the following is true about comments? | ||||
Option 1 : They are executed only once. | Option 2 : They are not executed | Option 3 : A good program does not contain them | Option 4 : They increase program execution time. | |
|
||||
Ques 114 : Choose the correct answer | ||||
Neelam wants to share her code with a colleague, who may modify it. Thus she wants to include the date of the program creation, the author and other information with the program. What component should she use? | ||||
Option 1 : Header files | Option 2 : Iteration | Option 3 : Comments | Option 4 : Preprocessor directive | |
|
||||
Ques 115 : Choose the correct answer | ||||
Shashi writes a program in C++ and passes it on to Pankaj. Pankaj does some indentation in some statements of the code. What will this lead to? | ||||
Option 1 : Faster Execution | Option 2 : Lower memory requirement | Option 3 : Correction of errors | Option 4 : Better readability | |
|
||||
Ques 116 : Choose the correct answer | ||||
Zenab and Shashi independently write a program to find the the mass of one mole of water, which includes mass of hydrogen and oxygen. Zenab defines the variables: integer hydrogen, oxygen, water // Code A while Shashi defines the three quantities as: integer a, b, c // Code BWhich is a better programming practice and why? |
||||
Option 1 : Code B is better because variable names are shorter | Option 2 : Code A is better because the variable names are understandable and non-confusing | Option 3 : Code A will run correctly, while Code B will give an error. | Option 4 : Code B will run correctly, while Code A will give an error. | |
|
||||
Ques 117 : Choose the correct answer | ||||
For solving a problem, which of these is the first step in developing a working program for it? | ||||
Option 1 : Writing the program in the programming language | Option 2 : Writing a step-by-step algorithm to solve the problem. | Option 3 : Compiling the libraries required. | Option 4 : Code debugging | |
|
||||
Ques 118 : Choose the correct answer | ||||
A robust program has which one of the following features? | ||||
Option 1 : It runs correctly on some inputs | Option 2 : It is robust to hardware damage | Option 3 : It can handle incorrect input data or data types. | Option 4 : None of these | |
|
||||
Ques 119 : Choose the correct answer | ||||
Tarun wants to write a code to divide two numbers. He wants to warn the user and terminate the program if he or she enters 0 as the divisor. Which programming construct can he use to do this? | ||||
Option 1 : Iteration | Option 2 : Decision-making | Option 3 : Recursion | Option 4 : None of these | |
|
||||
Ques 120 : Choose the correct answer | ||||
To solve a problem, it is broken in to a sequence of smaller sub-problems, till a stage that the sub-problem can be easily solved. What is this design approach called? | ||||
Option 1 : Top-down Approach | Option 2 : Bottom-Up Approach | Option 3 : Procedural Programming | Option 4 : None of these |
Placement Written test paper for MNC || Computer questions and answers Part – 4
Recent Post
Text Summarization Project using Flutter and Python
September 5, 2023
Spring boot Project Configuration Tutorial
August 28, 2023
Create Simple calculator using HTML, CSS and JS
August 2, 2023
How to Change name of java maven web project
April 12, 2023