Whats wrong with this code....

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    while(1){
    if((0<x<=2000)&&(0<=y<=2000))
    {
                                    if((x<=y)&&(x%5==0))
                                    cout<<y;
                                    //else if((x/2)>y)
                                  //  cout<<y;
                                  //  else
                                  //  cout<<y;
                                    
                                    else
                                    {
                                        break;
                                        }
                                    }}
                                    getch();
                                    return 0;
                                    }

I want to print the single value of y.I do not find the error of the code.

if(0<x<=2000)

This does not do what you think it does. This does not check that x is greater than zero and less than, or equal to, 2000.

This does not do what you think it does. This does not check that x is greater than zero and less than, or equal to, 2000.

Then what it does?
How can I will check the condition?

if ( (0 < x) &&
     (x <= 2000) )

This says: if ( x is greater than zero AND x is less than or equal to 2000)

Edited 5 Years Ago by Moschops: n/a

Then what it does?

0<x<=2000 will be parsed as (0 < x) <= 2000 . Or, depending on the value of x, either 0 <= 2000 or 1 <= 2000 since false and true evaluate to 0 and 1, respectively.

This article has been dead for over six months. Start a new discussion instead.