explain fragment of code

can someone explain the ouput of these 2 portions of code to me, i got it wrong an a quiz but didnt know how to answer it...
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<stdio.h>
main(){
unsigned int x=17,y=14;
printf("%d\n",(unsigned int)(x&y) );

//answer is 16

unsigned int w=17,z=14;
printf("%d\n",(unsigned int)(w&&z) );

//answer is 1

}
&&, and
logical operator, it returns true if both operands are true
0 is considered false, other numbers are true

&, bitand
bitwise operator, performs an `and' operation on each bit of the operands
in your example
17 = 10001
14 = 01110
 0 = 00000

(note that the answer is 0, not 16)
Topic archived. No new replies allowed.