Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. // Work_7.h
  2. // Programing_Basics_Lab07
  3. //
  4. // Created by Sergiy on 20.02.17.
  5.  
  6. #include <stdlib.h>
  7. #include <iostream>
  8. #include <math.h>
  9.  
  10. double calculate_Y(double A, double B, double x)
  11. {
  12. double y;
  13.  
  14. y = pow((A+B), 2) * sqrt((A+x)/(B+x)) * log((A+x));
  15.  
  16. return y;
  17. }
  18.  
  19. //-------------------------------
  20.  
  21. // main.cpp
  22. // Programing_Basics_Lab07
  23. //
  24. // Created by Sergiy on 20.02.17.
  25.  
  26. #include <iostream>
  27. #include <stdio.h>
  28. #include <math.h>
  29. #include "Work_7.h"
  30.  
  31. #define A 5
  32. #define B 7
  33.  
  34. int main(int argc, const char * argv[])
  35. {
  36. double x, y;
  37.  
  38. printf("\nThe value of A is %d and the value of B is %d\n", A, B);
  39. printf("\nFor calculation (y = ((a+b) to the power of 2) х (sqrt from (a+x)/(b+x)) x ln(a+x)), enter the value of X (there is a logarithm in calculations, so the value of x have to be greater then -5):\n");
  40.  
  41. scanf("%lf", &x);
  42.  
  43. if (x <= -5)
  44. {
  45. printf("\nThere is a logarithm in calculations, so the value of x have to be greater then -5. Try again!\n");
  46. exit(1);
  47. }
  48.  
  49. y = calculate_Y((double)A, (double)B, x);
  50.  
  51. std::cout << "Table: Result of calculations\n";
  52. std::cout << "-------------------------------------------------------------\n";
  53. printf("| A = 5 | B = 7 | x = %-10.2lf | y = %20.2lf |\n", x, y);
  54. std::cout << "-------------------------------------------------------------\n";
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement