LAB1_Task2
unknown
c_cpp
3 years ago
793 B
6
Indexable
#include <iostream>
using namespace std;
int operation(int x, int y, int z);
int main()
{
int x, y, z;
cout << "\nInput x, y, z: " << endl;
cin >> x >> y >> z;
cout << endl;
const int COMPARABLE = 20;
const int TARGET = 120;
int sum = x + y + z;
int result = operation(sum, COMPARABLE, TARGET);
cout << "\nResult of calculation: " << endl;
cout << "sum of elements x, y, z is " << sum << ' ';
if(!result)
cout <<"and it's greater than/equals to " << COMPARABLE;
else
cout << "and it's less than " << COMPARABLE << " and " << result << " is left to reach " << TARGET;
return 0;
}
int operation(int sum, int comparable, int target)
{
if(sum >= comparable)
return 0;
return target - sum;
}
Editor is loading...