Write a program that calculate the square root of a given number
1 2 3 4 5 6 7 8 9 10 11 | #include <stdio.h> #include <math.h> void main (void) { double x = 0.0, square_root = 0.0; printf("Enter a number: "); scanf("%lf", &x); if (x > 0) square_root = sqrt(x); printf("SquareRoot = %2.2lf", square_root); } |
Result:
Enter a number: 16 SquareRoot = 4.00
No comments:
Post a Comment