dimanche 25 juillet 2021

IF case statement [duplicate]

within the case 2 i have used a if statement that checks the following conditions if(a1 != a2 || l1 == l2 || length != l1 + l2) where the input of length,l1,l2,a1,a2 is prompted by the user

  case 2:
     {
        a1 = getarea(d1);
        a2 = getarea(d2);
        l1 = getlength();
       
        l2 = length-l1;

        if(a1 != a2 || l1 == l2 || length != l1 + l2) 
        {
           printf("Values entered do not match the case criteria\n");
           goto b;
        }
         
        break;
     }

if i have taken the length = 6.28 ,a1 = 0.002 , a2 = 0.002 , l1 = 1.8 then l2 becomes 5 which doesnt satisfes any of the condition in the if statement ( a1 != a2 ) as d1(0.002)=d2(0.002) which causes a1 = a2 , (l1 == l2 ) as ( 1.28 != 5) and ( Length = l1 + l2 ) as ( 6.28 = 1.28 + 5) but the program still enters the if statement.

enter image description here

Aucun commentaire:

Enregistrer un commentaire