I want:
111 || 100 ---> 111, not 1
100 && 100 ---> 100, not 1
101 && 010 ---> 000, not 0
Broken code
#include <stdio.h>
main(void){
string hexa = 0xff;
strig hexa2 = 0xf1;
// CONVERT TO INT??? cast
int hexa3 = hexa || hexa2;
int hexa4 = hexa && hexa2;
puts(hexa3);
puts(hexa4);
}
You want the bitwise operators (
|,&) instead of the logical operators (||,&&):As for your broken code, you also have incorrect types for
hexaandhexbwhich should both be numeric types:Finally, to output an integer, you would use
printfto format them: