Briefly explain what is wrong with the code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Briefly explain what is wrong with the code.

int x, y; cout << "Enter x and y: "; cin >> x >> y; cout << "product = " << x * y << endl; cout << "ratio = " << x / y << endl; cout << "sum = " << x + y << endl;

14th Dec 2020, 3:14 PM
sarah johnathon
sarah johnathon - avatar
2 Answers
+ 4
Well, what does it say? I can't work off of just this, you need to tell us what's the actual problem. The only thing I can think of here is you're dividing two integers which results in an int, you probably want a fractional result so you should cast one of these to either a float or a double.
14th Dec 2020, 3:28 PM
inxanedev!
inxanedev! - avatar
0
sarah johnathon There is nothing wrong. Program is working well.
14th Dec 2020, 5:01 PM
A͢J
A͢J - avatar