🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित प्रोग्राम का आउटपुट क्या है?

What is the output of the following program?

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)
B)
C)
D)

Explanation:

Let's analyze the given 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() { }

Explanation:

  • The program defines a String variable my_str with the value "This is the sentence".
  • It then calls the replace() function, which replaces the word "sentence" with "Arduino sketch".
  • Finally, it prints the updated string using Serial.println().

Outcome:

  • The word "sentence" is replaced by "Arduino sketch", so the resulting string will be:
    • "This is the Arduino sketch"

Correct Answer:

(C) “This is the Arduino Sketch”.

Latest Updates