Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/* Basic_Strings sketch */ String text1 = This string; String text2 = has more text; String text3; // to be assigned within the sketch
/*
Basic_Strings sketch
*/
String text1 = "This string";
String text2 = " has more text";
String text3; // to be assigned within the sketch
void setup()
{
Serial.begin(9600);
Serial.print( text1);
Serial.print(" is ");
Serial.print(text1.length());
Serial.println(" characters long.");
Serial.print("text2 is ");
Serial.print(text2.length());
Serial.println(" characters long.");
text3 = text1+text2;
Serial.println("text3 contains: ");
Serial.println(text3);
Serial.println(text2.indexOf('m'));
Serial.println(text3.indexOf('m'));
}
void loop()
{
}
Here is the question below!
code 1
Modify the code according to the lecture in a way that it stops once the variable is close to
zero.
Code 2
when the variable is close to zero print the message in the serial monitor and stop
decrementing.
Code 3
Use addition operator to combine the values of text1 and text2
Make the program find the index of character m in both strings text2 and text3.
Change the data types String to char to try array of characters to assign text and
messages to the variables text1,text2 and text3
Replace text#.length() in the original code with strlen(text#)
Replace text#.concat(text#) in the original code with strcpy(text#,text#)
Using strcmp function, compare text3 with text1+text2.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started