Advertisement
fabis_sparks

lesson1.4

Mar 25th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7.  //Арифметические операции с переменными
  8.     int a, b, c, d, e;
  9.     float middle= 0.0;
  10.     cout.precision(5);
  11.     cin >> a >> b >> c >> d >> e;
  12.     cout << endl << a + b << endl;
  13.     cout << b * d << endl;
  14.     cout << e / d / a << endl;
  15.     cout << float((a + b + c + d + e)) / 5 << endl;
  16.     cout << e - d - c - b - a << endl;
  17.     // для выполнения операции и получения дробного результата необходимо привести int к double
  18.     // или мы могли написать не 'int a,b,c,d,e', a 'float a,b,c,d,e'
  19.     // тогда не нужно было бы приводить к типу
  20.     middle = float((a + b + c + d + e)) / 5;
  21.     cout << "Sr arifm: " << middle << endl;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement