Mahindra Comviva Iteration, Recursion, Decision Problems with Solutions Quiz -1

Question 1

Time: 00:00:00
function main()
{
integer a=5,b=7
switch(a)
{
case 5 :print "I am 5"
break
case b:print "I am not 5"
break
default:print "I am different"
}
}

I am 5

I am 5

I am not 5

I am not 5

I am different

I am different

Error

Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition Which of the following options should she use such that the body of the loop/condition is executed atleast once whether the variable satisfies the entering condition or not?

For Loop

For Loop

While Loop

While Loop

Do While Loop

Do While Loop

Switch Case

Switch Case

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
The construct “if (condition) then A else B” is for which of the following purposes?

1)
2)
3)
4)

Decision-Making

Decision-Making

Iteration

Iteration

Recursion

Recursion

Object Oriented Programming

Object Oriented Programming

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 4

Time: 00:00:00
Ravi and Rupali are asked to write a program to sum the rows of 2X2 matrices stored in the array A.
Ravi writes the following code (Code A):
for n = 0 to 1
sumRow1[n] = A[n][1] + A[n][2]
end
Rupali writes the following code (Code B):
sumRow1[0] = A[0][1] + A[0][2]
sumRow1[1] = A[1][1] + A[1][2]
Comment upon these codes (Assume no loop­ unrolling done by compiler):

Code A will execute faster than Code B.

Code A will execute faster than Code B.

Code B will execute faster than Code A

Code B will execute faster than Code A

Code A is logically incorrect.

Code A is logically incorrect.

Code B is logically incorrect.

Code B is logically incorrect.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
Integer a =40, b =35, c=20, d =10
Comment about the output of the following two statements •
Print a*b/c-d
Print a*b/(c-d)

Comment about the output of the following two statements

Differ by 80

Differ by 80

Same

Same

Differ by 50

Differ by 50

Differ by 160

Differ by 160

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

The rule is DMOS 1.divide 2.multiply 3.operators 4.subtract a*b/c-d= 35/20(40)-10=60. a*b/(c-d)=35/10(40)=140 140-60=80

PrepInsta User

PrepInsta User

PrepInsta User

1st .............1400/20-10...........70-10..........60 2nd...........40*35/10.............1400/10......140 140-60=80

Question 6

Time: 00:00:00
What is the output of the following pseudo code?

Int a =456,b,c,d=10;
b=a/d;
c=a-b;
print c;

411.4

411.4

411

411

410.4

410.4

410

410

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

b will give only 45...because a & d are integer c=456-45=411

Question 7

Time: 00:00:00
Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition Which of the following options should she use such that the body of the loop/condition is executed atleast once whether the variable satisfies the entering condition or not?

For Loop

For Loop

While Loop

While Loop

Do While Loop

Do While Loop

Switch Case

Switch Case

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
The construct “if (condition) then A else B” is for which of the following purposes?

Decision-Making

Decision-Making

Iteration

Iteration

Recursion

Recursion

Object Oriented Programming

Object Oriented Programming

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
Function main()
{
Integer i=0.7
Static float m=0.7
If(m equals i)
Print(“We are equal”)
Else If(m>i)
Print(“I am greater”)
Else
Print(“I am lesser”)

We are equal

We are equal

I am greater

I am greater

I am lesser

I am lesser

This code will generate an error

This code will generate an error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice! \r\n \r\n","Keep trying! \r\n \r\n","Not bad! \r\n \r\n","Good work! \r\n \r\n","Perfect! \r\n \r\n"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Comments