How do i fix this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do i fix this code?

Here is a code i wrote long ago: include <iostream> using namespace std; int main() { int x, y; cin >> x, y; x+=1; if (x<1&&y>5){ cout << //something something; } else { cout << "( " << x << " and " << y << " ???" << " )"; } return 0; } I tried to add &&y<100 to the if statement thing, but it shows that y is a really big number and idk why?? Does this make any sense? Does anyone know how i can make the int y 0 or tell me if i did something wrong? Sorry if this is confusing. Thanks!

20th Jun 2017, 11:14 AM
marty
marty - avatar
2 Answers
+ 7
cin >> x, y; will only assign user input to x and not y. Do this instead: cin >> x >> y; And then provide two input values.
20th Jun 2017, 12:07 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
int y = 0; //default value of 0
20th Jun 2017, 11:18 AM
jay
jay - avatar