fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void) {
  5. float b;
  6. // printf("Eneter a float number");
  7. printf("Enter a float number"); // Corrected typo
  8. fflush(stdout); // Send the buffer to the console so the user can see it
  9. int a=0;
  10. // a=5; -- Not required
  11. a=scanf("%f", &b); // See the manual page for reading floats
  12. if (a==0) // Need comparison operator not assignemnt
  13. {
  14. printf("scanf error: (%d)\n",a); // A better error message could be placed here
  15. }
  16. else
  17. {
  18. printf("%g\n", b); // Just to check the input with ideone - debugging
  19. printf("%g %g %g",floor(b), round(b), ceil(b));
  20. }
  21. return 0; // You need the semi-colon here
  22. }
Success #stdin #stdout 0s 2172KB
stdin
4.657
stdout
Enter a float number4.657
4 5 5