TANDJ1 Please help me to find difference in two if else

In the problem TANDJ1
I am getting the wrong answer with this code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
int t;
cin>>t;
while(t–)
{
int k,a,b,c,d;
cin>>a>>b>>c>>d>>k;
int dist = abs(c-a)+abs(d-b);
if(k<dist)
cout<<“No”;
else if((k-dist )%2 == 0 )
cout<<“yes”<<endl;
else
cout<<“No”<<endl;

}

return 0;

}

but if i write this if else condition instead of if else in above code then i got right answer
// if(k>=dist && (k-dist )%2 == 0)
// cout<<“yes”<<endl;
// else
// cout<<“No”<<endl;

so anyone please help me to find what is difference in between this if else
// if(k>=dist && (k-dist )%2 == 0)
// cout<<“yes”<<endl;
// else
// cout<<“No”<<endl;

and this if else if
if(k<dist)
cout<<“No”;
else if((k-dist )%2 == 0 )
cout<<“yes”<<endl;
else
cout<<“No”<<endl;

cause you are missing a endl :slight_smile:

3 Likes

oh! Thank you