Check solutions C++ operator quetion

Need help/ check if they are right, thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int a=3, b=5, x;
x= a/b + b/a +a%b + b%a; cout << x;    //  x=0+1+0+1= 2
y=float(b/a)+ float(b)/a; cout << y;   //  y=1.6+1=2.6
z=a*b/2; cout << z;                    //  z= 4
w=pow(b, a)+sqrt(a+b);  cout << w;     //  w=125+2sqrt(2)


int a=4, b=7, x; 
a++; --b;
x=a+b; cout<<"x"<< x;        //x=11

a=4; b=8
x=a++*--b; cout<<"x="<< x;   //x=35

a=3; b=5;
a+=3+b; b*=2;
x=a+b; cout<< "x="<< x;      //x=13  
Don't double-post across boards.
http://www.cplusplus.com/forum/beginner/154824/
Topic archived. No new replies allowed.