Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double calc(double x);
  5.  
  6.  
  7. int main(void)
  8. {
  9. /*Declaration of variables*/
  10. double input,
  11. output;
  12.  
  13. /*Print user interface*/
  14. printf("Enter a number x: ");
  15.  
  16. /*Scan for user input*/
  17. scanf("%lf", input);
  18.  
  19. /*Call to calculating function*/
  20. calc(input);
  21.  
  22. /*Print the calculated value*/
  23. printf("f(x) = %f\n", input );
  24.  
  25. /*Return value to operating system*/
  26. return 0;
  27. }
  28.  
  29. double calc(double x)
  30. {
  31. /*Function*/
  32. if ( ( ( x * x ) - ( 5 * x ) + 6 ) != 0 && ( ( 3 * x ) + 6 ) > 0 )
  33. {
  34. return ( ( 1 + ( ( x * x ) / ( sqrt( ( 3 * x ) + 6 ) ) ) ) / ( ( x * x) - ( 5 * x ) + ( 6 ) ) );
  35. }
  36. else
  37. {
  38. printf("f(x) is not defined\n");
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement