Help me in solving EXAMCHEF problem

My issue

include <stdio.h>
int main() {
int t;
scanf(“%d”,&t);
while(t–)
{
int x,y,z;
scanf(“%d\t”,&x);
scanf(“%d\t”,&y);
scanf(“%d”,&z);
if(((z/x*y)*100)>50){
printf(“YES\n”);
}
else{
printf(“NO”);
}
}

return 0;

}

what is the error

My code

#include <stdio.h>
int main() {
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int x,y,z;
        scanf("%d\t",&x);
        scanf("%d\t",&y);
        scanf("%d",&z);
        if(((z/x*y)*100)>50){
            printf("YES\n");
        }
        else{
        printf("NO");
        }
    }
    
	return 0;
}


Problem Link: Exams Practice Coding Problem - CodeChef

Errors in your code:

  • You declared integers, so when you divide there will be only rounded values. Change the declarations and input reading into float.
  • In the if condition, apply PARENTHESIS to avoid operator associativity or precedence.
    This Would work fine:
#include <stdio.h>
int main() {
    int t;
    scanf("%d",&t);
    while(t--)
    {
        float x,y,z;
        scanf("%f\t",&x);
        scanf("%f\t",&y);
        scanf("%f",&z);
        if(((z/(x*y))*100)>50){
            printf("YES\n");
        }
        else{
        printf("NO\n");
        }
    }
    
	return 0;
}