I'm trying to get all the results to add up and equal one number. Something is wrong.
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"Enter any 2 integers\n";
cin>>a>>b>>c;
cout<<"the sum of integers you have entered is equal to c"<<(a+b=c)<<endl;
cout<<"the product of the integers you have entered is equal to c"<<(a*b=c)<<en$
cout<<"the quotient of the integers you have entered is equal to c"<<(a/b=c)<<e$
cout<<"the difference of the integers you have entered is equal to c"<<(a-b=c)<$
cout<<"the sum of all the results you have entered is equal to c"<<(c+c+c+c)<<e$
cout<<"\nThe program is over\n";
}
the end didn't copy write but lines 10-14 all end in endl;
#include <iostream>
usingnamespace std;
int main()
{
double a, b, c = 0;
cout << "Enter any 2 integers: " << endl;
cin >> a >> b;
cout << "the sum of integers you have entered is equal to "
<< (c += a + b, a + b) << endl;
cout << "the product of the integers you have entered is equal to "
<< (c += a * b, a * b) << endl;
cout << "the quotient of the integers you have entered is equal to "
<< (c += a / b, a / b) << endl;
cout << "the difference of the integers you have entered is equal to "
<< (c += a - b, a - b) << endl;
cout << "the sum of all the results you have entered is equal to "
<< c << endl;
cout << endl << "The program is over" << endl;
return 0;
}
@Josue Molina: What does (c += a + b, a + b) do?
We can directly do cout << "the sum of integers you have entered is equal to " << a + b<< endl; right?
The only thing wrong with your source code is the multiple attempts to assign to an rvalue. You should assign the result of the arithmetic operations to a variable or write them directly to the standard output stream (shown below).
1 2 3 4
cout<<"the sum of integers you have entered is equal to c" <<(a+b) << endl;
cout<<"the product of the integers you have entered is equal to c" <<(a*b) << endl;
cout<<"the quotient of the integers you have entered is equal to c" <<(a/b) << endl;
cout<<"the difference of the integers you have entered is equal to c" <<(a-b) << endl;