What will be the output of the below C program?
#include <stdio.h>
#define ATICLEWORLD 0x01
#define AUTHOR 0x02
int main()
{
unsigned char test = 0x00;
test|=ATICLEWORLD;
test|=AUTHOR;
if(test & ATICLEWORLD)
{
printf("I am an Aticleworld");
}
if( test & AUTHOR)
{
printf(" Author");
}
return 0;
}
Output: I am an Aticleworld Author
Explanation:When we are OR-ing the test( unsigned char variable) with 0x01 and 0x02. The value of test will be 0x03 (because initially test value is 0x00). When we perform the And-ing operatotion on test with 0x01 and 0x02 then expresstion will return non-zero value, for example (0x00000011 & 0x00000001 => 0x00000010).
need an explanation for this answer? contact us directly to get an explanation for this answer