fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. // Function prototype
  5. float f(float x, float y);
  6.  
  7. int main() {
  8. float x, y, result;
  9.  
  10. // รับค่าจากแป้นพิมพ์
  11. printf("Enter x: ");
  12. scanf("%f", &x);
  13. printf("Enter y: ");
  14. scanf("%f", &y);
  15.  
  16. // คำนวณค่า f(x, y)
  17. result = f(x, y);
  18.  
  19. // แสดงผลลัพธ์
  20. printf("f(%.2f, %.2f) = %.2f\n", x, y, result);
  21.  
  22. return 0;
  23. }
  24.  
  25. // ฟังก์ชันคำนวณ f(x, y) = sqrt(x*x + y*y)
  26. float f(float x, float y) {
  27. return sqrt(x * x + y * y);
  28. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Enter x: Enter y: f(0.00, 0.00) = 0.00