jeudi 8 février 2018

If statement outputs 3 requirements even if only 1 is fulfilled

  if(a=b && a!=c && b!=c){
    printf("The numbers %d",a);
    printf(" and %d", b);
    printf(" are equal ");
}

if(a = c && a!= b && c != b ){
    printf("The numbers %d",a);
    printf(" and %d", c);
    printf(" are equal ");
}

if(c=b && c!=a && b!=a){
    printf("The numbers %d ",c);
    printf(" and %d ", b);
    printf(" are equal ");
}

This is my code, for some reason even if i specifed to the detail the requirements it still outputs all 3 versions of the if statement. Without != operator the output stays the same, any ideas why?

http://prntscr.com/ibz8k1 here is the output.

Aucun commentaire:

Enregistrer un commentaire