fork(2) download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>
  4.  
  5. int main(void)
  6.  
  7. {
  8.  
  9. float max=FLT_MIN, a;
  10. float min=FLT_MAX, b;
  11.  
  12. printf("Entering 0 will terminate the sequence of input values.\n");
  13.  
  14. do{ printf("Enter Number:");
  15.  
  16. if (scanf("%f", &a)==1)
  17. {
  18.  
  19. if ( fabs(a)<0.001 )
  20. break;
  21.  
  22. if(a>max){
  23.  
  24. max=a;}
  25.  
  26. if(a<min){
  27.  
  28. min=a;}
  29.  
  30. }
  31.  
  32. } while(fabs(a) > 0.001);
  33.  
  34. printf("Your largest number was %.3f. Your smallest number was %.3f.", max, min);
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 2252KB
stdin
1
2
3
-1
-2
-3
0
stdout
Entering 0 will terminate the sequence of input values.
Enter Number:Enter Number:Enter Number:Enter Number:Enter Number:Enter Number:Enter Number:Your largest number was 3.000. Your smallest number was -3.000.