Help me in solving P1149 problem

My issue

include <stdio.h>
int main() { int x,y,k;

if (x > y) {
    if ((x - y) <= k) {
        printf("yes");
    }
    else {
        printf("no");
    }
}

else {
    if ((y - x) <= k) {
        printf("yes");
    }
    else {
        printf("no");
    }
}
return 0;

}

My code

#include <stdio.h>
int main() { int x,y,k;
   
    if (x > y) {
        if ((x - y) <= k) {
            printf("yes");
        }
        else {
            printf("no");
        }
    }

    else {
        if ((y - x) <= k) {
            printf("yes");
        }
        else {
            printf("no");
        }
    }
    return 0;

}

Problem Link: Approximate Answer Practice Coding Problem

this my code, and my code worked
</>
include <stdio.h>

int main(void) {
// your code goes here
int x,y,k;
int a;
scanf(ā€œ%d %d %dā€,&x,&y,&k);
if(x>y){
a=x-y;
}
else{
a=y-x;
}

if(a<=k){
    printf("YES");
}
else{
    printf("No");
}
return 0;

}

You did not take the input from the user

1 Like