fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void)
  5. {
  6.  
  7. double number;
  8. int roundedNumber;
  9. printf("Enter the number and \"end\"for end : ");
  10.  
  11. while((scanf("%lf", &number)) == 1 )
  12. {
  13. roundedNumber = floor(number + 0.5);
  14. printf("The original number is: %f\n", number);
  15. printf("The rounded number is: %d\n", roundedNumber);
  16. puts("");
  17. printf("Enter the number and \"end\"for end : ");
  18.  
  19. }
  20.  
  21.  
  22. }
  23.  
Success #stdin #stdout 0s 5288KB
stdin
5.2
5.5
5.7
6
end
stdout
Enter the number and "end"for end : The original number is: 5.200000
The rounded number is: 5

Enter the number and "end"for end : The original number is: 5.500000
The rounded number is: 6

Enter the number and "end"for end : The original number is: 5.700000
The rounded number is: 6

Enter the number and "end"for end : The original number is: 6.000000
The rounded number is: 6

Enter the number and "end"for end :