Program is always giving same output

I am having some issues with assigning a's and b's new values, using there old ones to calculate them.
My program output is always a=2 and b=1.
Can anybody help me with this please?

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

using namespace std;
int main()

{   	int A, B;					
	cout << " Enter the values of A and B without a comma separating the values. \n";
	cin >> A, B;				
if (A > B)								
{	A = A * B + 2;	//I'm not sure how to write this???			
	B ++;					
}
		else 									
		{  	A = A / 2;  //Also here 
	 	B = B + 4;  // and here I'm having problems with the syntax
			}
		cout << "A = " << A << " B = " << B;
		return 0;
	}




Enter the values of A and B without a comma separating the values.
(any number) (and any number)
A = 2 B = 1

Last edited on
cin >> A, B;

The comma operator doesn't do what you think it does. Do this instead:

cin >> A >> B;
oh crap! I can't believe i missed that! Sorry sometimes when I type fast I mistype :\

Ok, that being said. Even with the comma.
Why is it always giving a 2 and 1 output??? What does that comma do??
Topic archived. No new replies allowed.