Q:

What will be the output of the below C program?

0

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;
}

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

total answers (1)

Embedded C interview questions and answers (2022)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is meant by structure padding?... >>
<< Write a program swap two numbers without using the...