I am completely lost. I dont know if i'm using the correct format for this program. This is just an excerise program. I'm studying and I can't seem to figure this out. the excersie ask to write a program that inputs 3 integers and outputs either the word yes or the word no. program should output yes when any of the integers equals the sum of the other two intergers. and output no if there is no number that is the sum of the other two. pleas help!!! I have included the code i'm working on but I know its not correct because it wont run.
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
// input
cout << "enter three numbers";
cout << "seperated by spaces" << endl;
int number1;
int number2;
int number3;
cin >> number1 >> number2 >> number3;
cin.ignore(99,'\n');
// process
int sum1 = number1 + number2;
int sum2 = number1 + number3;
int sum3 = number2 + number3;
int sum4 = number2 + number1;
int sum5 = number3 + number1;
int sum6 = number3 + number2;
//
if (sum1 == number3)
if (sum2 == number2)
if (sum4 == number3)
if (sum3 == number1)
if (sum6 == number1)
if (sum5 == number2)
You are almost right just remove this from your code
1 2 3 4 5 6
if (sum1 == number3)
if (sum2 == number2)
if (sum4 == number3)
if (sum3 == number1)
if (sum6 == number1)
if (sum5 == number2)
This will allow bool to initialize iff sum5 == number2....
That's what causing you trouble for your program....
one suggestion is there rather than using string word,
you can directly use
Thanks for your help!! I think my program works now. I was having such a hard time figuring out what I was doing wrong. Not only that this whole if statements and booleans is kinda tricky. Thanks again!