Question 1

Time: 00:00:00
How many iteration are done to find 7 using binary search in pseudocode?
#include<iostream>
using namespace std;
int main()
{
arr[5] = {2, 6, 7, 9, 10};
return 0;
}

2

2

3

3

1

1

4

4

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

Please login to submit your explanation

Question 2

Time: 00:00:00
Find the output of the following code?
#include<iostream>
using namespace std;
int main(){
int arr[6]= {2,4,6,8,10,12};
for(int i=0;i<6;i+=3){
cout<<arr[i]<<" ";
}
return 0;
}

2 6 10

2 6 10

4 8 12

4 8 12

2 8

2 8

2 10

2 10

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

Please login to submit your explanation

Question 3

Time: 00:00:00
What is the value of sum in the following code for n =5?
#include<iostream>
using namespace std;
int main(){
int n, sum =0;
int i=0;
while(i<=n){
sum = i+n;
i+=2;
}
cout<<sum;
return 0;
}

5,8,10

5,8,10

5,7,9

5,7,9

6,8,10

6,8,10

5,7,8

5,7,8

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

Please login to submit your explanation

Question 4

Time: 00:00:00
What will be the output of the following code ?
#include<iostream>
using namespace std;
int main(){
string str = "Prepinsta";
string s;
for(int i=0;i<str.length(); i+=2){
s += str[i];
}
s.pop_back();
cout<<s;
return 0;
}

Peis

Peis

Peisa

Peisa

eisa

eisa

Pisa

Pisa

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

Please login to submit your explanation

Question 5

Time: 00:00:00
What will be the output of the code?
#include<iostream>
using namespace std;
int main(){
string str = "*";
string s;
for(int i=0;i<10; i+=3){
s += str[0];
if(i%2!=0) s+= "#";
}
cout<<s;
return 0;
}

**#**#

**#**#

#**#**

#**#**

***#***#

***#***#

#***#*

#***#*

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

Please login to submit your explanation

Question 6

Time: 00:00:00
what is the output of the following code?
#include
using namespace std;
int main(){
int ans = ' ' * 10;
cout<<ans;
return 0;
}

320

320

10

10

20

20

340

340

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

Please login to submit your explanation

Question 7

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

using namespace std;
int main(){
int arr[5] = {2,4,3,5,6,};
for(int i=0 ; i<3; i++){
arr[i] = arr[i+1] + arr[i+2];
}
for(int i=0;i<5;i++){
cout<<arr[i]<<" ";
}
return 0;
}

7 8 11 8 9

7 8 11 8 9

7 8 11 5 6

7 8 11 5 6

1 3 4 5 6

1 3 4 5 6

8 5 3 2 10

8 5 3 2 10

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

Please login to submit your explanation

Question 8

Time: 00:00:00
What will following code do?
#include<iostream>
using namespace std;
int main(){
string s = "prepinsta";
int i=0;
for(int j=s.length()-1; j>=0; j--){
cout<<s[i];
i++;
}
return 0;
}

Reverse the string

Reverse the string

Don’t change the string

Don’t change the string

Remove the characters from string

Remove the characters from string

Print half characters from string

Print half characters from string

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

Please login to submit your explanation

Question 9

Time: 00:00:00
What will be the output of the following code?

using namespace std;
int main(){
string s = "prepinsta";
int i=0;
for(int j=s.length()-1; j>=4; j--){
cout<<s[i];
i+=2;
}
return 0;
}

peisa

peisa

ppnta

ppnta

pepsa

pepsa

peita

peita

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

Please login to submit your explanation

Question 10

Time: 00:00:00
What will code do the ?
#include<iostream>
using namespace std;
int main(){
string str = "prepinsta";
int i=0, j=str.length()-1;
while(i<=j){
swap(str[i],str[j]);
i++;
j--;
}
return 0;
}

Don’t change the string

Don’t change the string

Reverse the string

Reverse the string

Swap the last character

Swap the last character

Delete the middle character

Delete the middle character

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!","Keep trying!","Not bad!","Good work!","Perfect!"]

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