Q.1

Assuming a integer 2-bytes, What will be the output of the program?

#include<stdio.h>

int main()
{
    printf("%x\n", -1<<3);
    return}
  • ffff
  • fff8
  • -1
Q.2

Which of the following statements are correct about the program?

#include<stdio.h>
char *fun(unsigned int num, int base);

int main()
{
    char *s;
    s=fun(2);
    s=fun(16);
    printf("%s\n",s);
    return}
char *fun(unsigned int num, int base)
{
    static char buff[33];
    char *ptr = &buff[sizeof(buff)-1];
    *ptr = '\0';
    do
    {
        *--ptr = "0123456789abcdef"[num %base];
        num /=base;
    }while(num!=0);
    return ptr;
}
  • It converts a number to a given base.
  • It converts a number to its equivalent binary.
  • It converts a number to its equivalent hexadecimal.
  • It converts a number to its equivalent octal.
Q.3

On left shifting, the bits from the left are rotated and brought to the right and accommodated where there is empty space on the right?

  • True
  • False
Q.4

Bitwise & and | are unary operators

  • True
  • False
Q.5

What will be the output of the program?

#include<stdio.h>

int main()
{
    char c=    int i, mask=    for(i=i<=i++)
    {
        printf("%c", c|mask);
        mask = mask<<    }
    return}
  • 12400
  • 12480
  • 12500
  • 12556
Q.6

Which bitwise operator is suitable for checking whether a particular bit is on or off?

  • && operator
  • & operator
  • || operator
  • ! operator
Q.7

What will be the output of the program ?

#include<stdio.h>

int main()
{
    int i=j=
    printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j);
    return
}
  • 4, 8, 0
  • 1, 2, 1
  • 12, 1, 12
  • 0, 0, 0
Q.8

If an unsigned int is 2 bytes wide then, What will be the output of the program ?

#include<stdio.h>

int main()
{
    unsigned int a=0xffff;
    ~a;
    printf("%x\n", a);
    return}
  • ffff
  • 0000
  • 00ff
  • ddfd
Q.9

Which of the following statements are correct about the program?

#include<stdio.h>

int main()
{
    unsigned int m[] = {0x0x0x0x0x0x0x0x80};
    unsigned char n, i;
    scanf("%d", &n);
    for(i=i<=i++)
    {
        if(n & m[i])
            printf("yes");
    }
    return
}
  • It will put OFF all bits that are ON in the number n
  • It will test whether the individual bits of n are ON or OFF
  • It will put ON all bits that are OFF in the number n
  • It will report compilation errors in the if statement.
Q.10

Bitwise & can be used to check if more than one bit in a number is on.

  • True
  • False
Q.11

What will be the output of the program?

#define P printf("%d\n", -1^~0);
#define M(P) int main()\
             {\
                P\
                return 0;\
             }
M(P)
  • 1
  • 0
  • -1
  • 2
Q.12

What will be the output of the program?

#include<stdio.h>

int main()
{
    unsigned char i = 0x    printf("%d\n", i<<1);
    return}
  • 0
  • 256
  • 100
  • 80
Q.13

Bitwise & can be used to check if a bit in number is set or not.

  • True
  • False
Q.14

What will be the output of the program ?

#include<stdio.h>

int main()
{
    int i=j=0xk, l, m;
    k=i|j;
    l=i&j;
    m=k^l;
    printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
    return
}
  • 0, 0, 0, 0, 0
  • 0, 32, 32, 32, 32
  • 32, 32, 32, 32, 0
  • 32, 32, 32, 32, 32
Q.15

What will be the output of the program?

#include<stdio.h>

int main()
{
    printf("%d %d\n", 32<<32<<0);
    printf("%d %d\n", 32<<-32<<-0);
    printf("%d %d\n", 32>>32>>0);
    printf("%d %d\n", 32>>-32>>-0);
    return}
  • Garbage values
  • 64 32
    0 32
    16 32
    0 32
  • All zeros
  • 8 0
    0 0
    32 0
    0 16
0 h : 0 m : 1 s