Answer to Question #263768 in C++ for sugandi

Question #263768

when the user enters three number show him true if the total of two numbers is equal to the third.


1
Expert's answer
2021-11-10T03:01:28-0500
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> vec(3);
  for (int i=0; i<3; i++)
    cin>>vec[i];
  sort(vec.begin(), vec.end());
  if (vec[0]+vec[1]==vec[2])
    cout << true << endl;
  else
    cout << false << endl;
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS