#include <stdio.h>
#include <math.h>
int main() {
double number, result;
// Input the number
printf("Enter a number to find its square root: ");
scanf("%lf", &number);
if (number < 0) {
printf("Error: Cannot compute the square root of a negative number.\n");
} else {
// Calculate the square root
result = sqrt(number);
printf("Square root of %.2f is %.2f\n", number, result);
}
return 0;
}
Comments
Post a Comment