What is the output of the following program? [code] void setup() { String my_str = "This is the sentence"; Serial.begin(9600);

Nguyễn Trà

New member
What is the output of the following program?
Code:
void setup() { 
    String my_str = "This is the sentence"; 
    Serial.begin(9600); 
    my_str.replace("sentence", "Arduino sketch"); 
    Serial.println(my_str);
}
void loop() { }
A. “This is the sentence”
B. “This is the ARDUINO SKETCH”
C. “This is the Arduino Sketch”
D. null
 
Answer: C
Explanation: The code given here, takes a string and then proceeds to replace the value of the string with custom word(s). It is an example of String manipulation in Arduino. It uses the replace() function for achieving this.
 

Tìm kiếm

Back
Top