mercredi 17 juin 2020

If else check failed in the program

I have the following section in my program:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main ()
{
   double a, b, c, check;
   check = (pow(a,2) + pow(b,2) + pow(c,2));

   if (check !=1 )
   {
        printf("a^2+b^+c^2 = %f, and is not equal to 1\n", check);
        printf("do something\n");
   }
   else
   {
        //conginue with something
   }
}

When I run the program, the if else condition fails even when the value of check is 1.

I get the following message:

The value of a^2+b^2+c^2 is 1.000000 and is not equal to 1.

I tried to do it with

if (check !=1.000000 )

and still the result is same.

Can any one help me with this?

Aucun commentaire:

Enregistrer un commentaire