ok so i got this code and x=1.5 and y= -2.5
instead of giving me a=0 and b= -3, it gives me a=0 b=0...
can you guyz please explain me why ? and the answer please?
here is the code (using codeblocks..)
#include <iostream>
#include <cmath>
usingnamespace std;
int main ()
{
int a,b,w;
double x,y;
cin>>x>>y; // x = 1.5, y = -2.5
a=x*y; // 1.5 * (-2.5) = -3.75 = -3 because a is an int
b=x/y; // 1.5 / -2.5 = -0.6 = 0 because b is an int
if(a<b){ // true because -3 < 0
w=a; // w = -3
a=b; // a = 0
b=a; // b = 0
}
if(x != int(x)){ // true because 1.5 != 1
cout<<a<<' '<<b; // prints "0 0"
}
else cout<<b<<' '<<a;
}