Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6.  
  7. int main()
  8. {
  9. const double ANSWER = 3.14159;
  10. double response;
  11.  
  12. printf("what is the value of pi?\n");
  13. scanf("%lf", &response);
  14. //printf("%lf",fabs(response-ANSWER));
  15. while (fabs(response-ANSWER)>0.0001)
  16. {
  17. //printf("%lf",fabs(response-ANSWER));
  18. printf("try again!\n");
  19. scanf("%lf", response);
  20. }
  21.  
  22. printf("close enough!\n");
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement