fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. double i; // ใช้ double
  5. double y = 0.0; // ถ้าต้องการเก็บค่าท้าย
  6.  
  7. for (i = 0.0; i < 1.0; i += 0.01) {
  8. // ถ้าไม่อยากปริ้นทุกค่า ก็ไม่ต้อง printf ใน loop
  9. y = i; // เก็บค่าล่าสุด
  10. }
  11.  
  12. printf("ค่าท้าย = %f\n", y); // ปริ้นแค่ค่าท้าย
  13. return 0;
  14. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
ค่าท้าย = 0.990000