0
int main(int argc, char *argv[])
{
    int mobile, pond;
    float a;
    cout<< "input mobile price:";
    cin>>mobile;

    cout<< "input 1 pound how many BTH:";
    cin>>pond;

mobile+pond==a



    cout<<a;

Edited by Reverend Jim: Fixed formatting

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Nick Evan
0

And your question?

No, it won't compile.
No, you didn't read the intro threads on how to post code.
No, I won't guess what you wanted.

0

"mobile+pond==a"

What you are doing is comparing with the '==' bool operator.
What you are saying with this statement is :
Is mobile plus pond equal to a? If so say true else say false.

What you want to do is use the assignment operator '='.
Setting a = mobile + pond.

This assigns a to what mobile represents plus what pond
represents.

Its might be easier to examine with numbers.

your statement :

mobile+pond==a

Let mobile = 5, and pond = 5, the above statement becomes
5 + 5 == a?
Is 5 plus 5 equal to a? But a is not initialized to anything so this
would be junk.

But this statement :

a = mobile + pond;

Let mobile = 5, and pond = 5 then the above statement becomes
a = 5 + 5;
a = 10;

This assigns a to 10. And now a has a good value and is not
full of junk.

0

But this statement :

a = mobile + pond

Let mobile = 5, and pond = 5 then the above statement becomes
a = 5 + 5;
a = 10;

I'd add a semicolon if I were you, just to keep the compiler happy :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.