Newbie Question

Hey guys, I have a pretty simple question, regarding why my program is not working... I know this is a REALLY easy program, I'm just tired and messing around with code to practice, and I'm totally stuck on something really simple...

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>

using namespace std;

void choice1();
int main()
{
    int choice;
    char quit;
    do
    {
    cout << "Welcome to Kyle's Math Program!" << endl;
    cout << "This program will answer basic math questions"<< endl;
    cout << "Such as Adding/Subracting/Multiplying/Dividing two numbers" << endl;
    cout << "Press 1 to insert an Addition question" << endl;
    cout << "Press 2 to insert a Subtraction question" << endl;
    cout << "Press 3 to insert a Multiplication question"  << endl;
    cout << "Press 4 to insert a division question"  << endl;

    if(choice==1)
    {
        choice1();
    }

    cout<<"Do you want to continue (Y/N)?";
    cin>>quit;
    }
    while(quit=='y'||quit=='Y');
}
void choice1()
{
    int a = 1;
    int b = 1;
    int solution;
    cout << "Alright, lets do some Addition!" << endl;
    cout << "Enter the first number" << endl;
    cin >> a >> endl;
    cout << "Alright, now enter what you wish to add to that" << endl;
    cin >> b >> endl;
    a + b = solution;
    cout << "Those two numbers added together is equal to" << solution << endl;
}



On line 39 I get a compiling error stating

main.cpp|39|error: no match for 'operator>>' in 'std::cin.std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(& b))) >> std::endl'|



Could someone please help me point out my problem? So I can gain my sanity and possibly fall asleep tonight knowing I accomplished my mission?
cin >> a >> endl;

endl is not a variable, so you can't input to it.

only use endl with output streams like cout. Not with input streams like cin.
Ahh Thanks!

I replace >> endl; and simply placed a semicolon.

Now it seem though that I'm receiving yet another error...

LINE 40
error: lvalue required as left operand of assignment|


I don't see how that is incorrect, I used cin on both variables, and now I'm simply adding the two numbers?
Assignment works right to left.

That is:

 
variable_being_assigned = value_you_assign_to_that_variable;


So...

1
2
3
4
5
6
7
int a;

// this makes sense:
a = 5;  // assigning 5 to our variable a

// this makes no sense
5 = a; // how can we assign something to 5?  nonsense! 
Ohh!

I completely forgot about that... I really need to go get some sleep!

Thanks a ton, I still can't believe I forgot something so basic! Arrrrh!

Cheers
Topic archived. No new replies allowed.