Find Square root of Number
#include <stdio.h>
#include <math.h>
int main() {
double num, squareRoot;
printf("Enter a number: ");
scanf("%lf", &num);
if (num >= 0) {
squareRoot = sqrt(num);
printf("Square root of %.2lf is %.2lf\n", num, squareRoot);
} else {
printf("Cannot compute the square root of a negative number.\n");
}
return 0;
}
Comments
Post a Comment