Programming Examples
Arduino program to print the square root of a given number
Arduino program to print the square root of a given number
Solution
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
float number = Serial.parseFloat();
float squareRootValue = sqrt(number);
Serial.print("Square Root of ");
Serial.print(number);
Serial.print(" is: ");
Serial.println(squareRootValue);
}
}
Output
Square Root of 25.00 is: 5.00