fork download
  1. #include <stdio.h>
  2. #include <math.h> // Include math.h for sqrt() function
  3.  
  4. int main() {
  5. double num, square, cube, squareRoot;
  6.  
  7. // Input the number from the user
  8. printf("Enter a number: ");
  9. scanf("%lf", &num);
  10.  
  11. // Calculate square, cube, and square root
  12. square = num * num;
  13. cube = num * num * num;
  14. squareRoot = sqrt(num); // Using sqrt() from math.h to calculate the square root
  15.  
  16. // Output the results
  17. printf("Square of %.2f is: %.2f\n", num, square);
  18. printf("Cube of %.2f is: %.2f\n", num, cube);
  19. printf("Square root of %.2f is: %.2f\n", num, squareRoot);
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5288KB
stdin
25
stdout
Enter a number: Square of 25.00 is: 625.00
Cube of 25.00 is: 15625.00
Square root of 25.00 is: 5.00