Question
Asked Oct 8, 2019
15 views
Question 1: What does the following code output?
"Hello you, this is not a robot";
string str1
= str1.substr (11, 30);
string str2
cout <<"1:
<< str2 << endl;
str1.find( "you", 0 );
int found
<< found << endl;
cout << "2:
found str1.find( "you", 10 );
< found <« endl;
cout << "3:
"This is an easy question";
string str3 =
string str4;
int count= 0;
stringstream ss (str3);
ss str4 )
while
count++
< str4 < endl;
< count << ",
cout << "4:
//write output here:
1:
2:
3:
4:
help_outline

Image Transcriptionclose

Question 1: What does the following code output? "Hello you, this is not a robot"; string str1 = str1.substr (11, 30); string str2 cout <<"1: << str2 << endl; str1.find( "you", 0 ); int found << found << endl; cout << "2: found str1.find( "you", 10 ); < found <« endl; cout << "3: "This is an easy question"; string str3 = string str4; int count= 0; stringstream ss (str3); ss str4 ) while count++ < str4 < endl; < count << ", cout << "4: //write output here: 1: 2: 3: 4:

fullscreen
check_circle

Expert Answer

Step 1

 

Program explanation: 

  • The String variable “str1” is initialized to “Hello you, this is not a robot”.
  • The String variable “str2” is assigned with the substring of “str1”.
  • Print the value stored in “str2”.
  • The variable “found” is declared as “int” and it uses the “find()” method to check whether the string “you” is present in the “str1”.
  • Print the value stored in “found”.
  • Using the “find()” to check whether...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Object Oriented Programming

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Boolean Logic Draw the truth table for the following functions: F(A,B)=AB+(A+B) F(A,B,C)=AB+BC+...

A: Hey, since there are multiple questions posted, we will answer first question. If you want any speci...

question_answer

Q: In C++ Ask the user for three friends names, store the names in an array.  Output the array to a fil...

A: Program://include the required header files#include &lt;iostream&gt;#include&lt;fstream&gt;#include ...

question_answer

Q: Can a python programmer write a program that takes a picture of its own source code and then hides a...

A: Python is a general purpose, interpreted, high level programming language that is used for developin...

question_answer

Q: Use K-Maps to simplify each of the following: ~x~y~z + ~xyz + ~xy~z ~x~y~z + ~xy~z + x~y~z + xy~z ~...

A: Since there are 3 variables we construct the K-Map as follows and find the minimal cover of the map ...

question_answer

Q: Please explain all steps: What Boolean equation is represented by the following K-Maps: a)    ...

A: K-Map simplificationFor 3 variables adjacent groups of 2 cells, or 4 cells (1 x4 or 2 x 2), for 4 va...

question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Solution:The C++ program has the following algorithm:Declare and initialize the required variables.D...

question_answer

Q: A bit confused on where to begin this program. I'm confused by the information I'm being given I thi...

A: In this program user wants to perform following tasks:    1.Taking inputs as a (A, B, C).     2. Cal...

question_answer

Q: I need some help arranging these countries in a C++ program : China: 1,433,783,686 India: 1,366,417,...

A: Program Instructions:Declare two arrays and store values of countries and populations in each of the...

question_answer

Q: Consider a program that declares global integer variables x, y[10]. Thesevariables are allocated sta...

A: Explanation of the code: lw $s1, 0($gp) #load value in base address to $s1addi $s1, $s1, 25 #increme...