Help me in solving LBCP02 problem

My issue

My code

// Update the program below to solve the problem

#include <stdio.h>

int main()
    int t;
    scanf("%d", &t);

    while (t--)
        int X, Y, Z;
        scanf("%d %d %d", &X, &Y, &Z);
        if((X%Z==0) && (Y%Z==0)){
                else if (Z%X ==0){
        else if(Y%Z==0){
        else {

    return 0;

Learning course: C for problem solving - 1
Problem Link: CodeChef: Practical coding for everyone

Hello friend!

Our logic is slightly wrong.

As Z is the total number of legs of the animals, it is a greater number than X and Y.

Hence, you should check Z % X == 0 && Z % Y == 0, instead of this, you did X%Z ==0 && Y%Z ==0, which is incorrect. Also, in the else if condition, it would be Z%Y ==0 and not Y%Z==0.

Hope this will help you!