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;

Recommended Answers

All 3 Replies

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.

"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.

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.