## Jboy05

a = 2;
b = 3;
a = (a + b) % 2;
b = b – a;
a = a * b;
cout << a << "\n" << b ;

What is the output for a and b?
------------------------------------------------------------
Why is a 3 and b 2 is this one

a = 2;

b = 3;

a = a + b;

b = a – b;

a = a – b;

cout <<a<<endl;

cout << b;

## Jboy05

can anyone offer some assitance in explainning?

## Narue 5,707

>What is the output for a and b?
Run it and see.

>Why is a 3 and b 2 is this one
2 + 3 = 5
5 - 3 = 2
5 - 2 = 3

## Jboy05

yea i ran it but got an error so i dont know

## Narue 5,707

>yea i ran it but got an error so i dont know
You probably got the same error I did. It's hard to see, but – and - are not the same character. If that doesn't fix your problem, post the errors you're getting and all of the code.

## Jboy05

i got a=3 and b=2 is that right?

## VernonDozier 2,218

You have two separate pieces of code. Which one are you asking about?

This one?

``````a = (a + b) % 2;
b = b – a;
a = a * b;``````

or this one?

``````a = a + b;
b = a – b;
a = a – b;``````

And do you still have the error?

the first one

## VernonDozier 2,218

I get a = 2 and b = 2.

## Jboy05

hmmm...can you explain how you got that?

## VernonDozier 2,218

By that do you mean:

1) Your program doesn't run still?