Help!

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;
Last edited on
closed account (jwkNwA7f)
You are asking to enter a number for c too, not just a and b.

<$
Should have two '<'s

Also, what are these?:
en$
e$
$
e$

Hope this helped!

EDIT: Please use code tags! If you are unsure on how to use them please view this article: http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Sadly, this program uses advanced constructs, so your instructor will believe you're cheating. ;-)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

using namespace 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?
when I copied the code it cut off the ends so it looks messed up...

And yes i wish i could use that but it is too advanced:)
closed account (2b5z8vqX)
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;
Topic archived. No new replies allowed.