dimanche 12 septembre 2021

what this condition means < if( c = (int) c) > in the below code

This is a code for pythagorean triplet. can somebodby explain the working of "if" statement below.

int main()
{
    int a, b;
    float c;

    //calculate the another side using Pythagoras Theorem
    //a*a + b*b = c*c
    //c = sqrt(a*a+b*b)
    //maximum length should be equal to 30
    for(a=1;a<=30;a++)
    {
        for(b=1;b<=30;b++)
        {
            c = sqrt(a*a+b*b);
            **if(c == (int)c)**
            {
                printf("(%d, %d, %d)\n",a,b,(int)c);
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire