Advertisement
RicoHeartless

LABORATORY #3

Mar 27th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. //LABORATORY #3
  2. //TASK 1
  3. #include <stdio.h>
  4. void main()
  5. {
  6.     unsigned a = 39;
  7.     char b = 150;
  8.     short c = 4;
  9.     int e = 24;
  10.     bool rez = (!a-- + -b-- | (!c-- > sizeof(float) ^ ++e));//Виконує обчислення логічної функції
  11.     printf("Result of calculations: %d\n", rez); //Виводить результат обчислення логічної функції
  12.     bool i1 = (!a-- + -b--); //По частинам (1 дужка)
  13.     bool i2 = (!c-- > sizeof(float) ^ ++e); // 2 дужка
  14.     bool i3 = i1 | i2; //Остання операція
  15.     printf("Result of calculations by parts:\n\tFirst operation:%d\tSecond operation:%d\tAll together:%d\n", i1, i2, i3);
  16. }
  17. //TASK 2
  18. #include <math.h>
  19. #include <iostream>
  20. using namespace std;
  21.  
  22. void main()
  23. {
  24.  
  25.     double x;
  26.     cout << "Enter value of X: ";
  27.     cin >> x;
  28.     double xmod = (fabs(x));
  29.     double y = log2(xmod);
  30.     cout << "\ny = " << y<<endl;
  31. }
  32. //TASK 3
  33. #define _USE_MATH_DEFINES
  34. #include <math.h>
  35. #include <iostream>
  36.  
  37. using namespace std;
  38.  
  39. void main()
  40. {
  41.     double x, y;
  42.     cout << "enter x: ";
  43.     cin >> x;
  44.     y = log(sqrt(2)) + fabs(cos(3 * x)) + exp(x + M_E) - atan((x*x) / 5) + sqrt(3.25 + x*x*x);
  45.     cout << "y = " << y << endl;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement