Sail E0 Webinar

MCQs

Total Questions : 35 | Page 2 of 4 pages
Question 11.

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


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True


Question 12.

Left shifting a number by 1 is always equivalent to multiplying it by 2.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

0001 => 1 
0010 => 2 
0100 => 4 
1000 => 8 


Question 13.

In the statement expression1 >> expression2. if expression1 is a signed integer with 

its leftmost bit set to 1 then on right shifting it the result of the statement will vary from 

computer to computer


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True


Question 14.

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


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True


Question 15.

Bitwise & and | are unary operators


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False

Bitwise & and | are not unary operators only bitwise ! is unary operator.


Question 16.


Which of the following statements are correct about the program?


#include<stdio.h>
int main()
{
unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
unsigned char n, i;
scanf("%d", &n);
for(i=0; i
  1.    It will put OFF all bits that are ON in the number n
  2.    It will test whether the individual bits of n are ON or OFF
  3.    It will put ON all bits that are OFF in the number n
  4.    It will report compilation errors in the if statement.
 Discuss Question
Answer: Option B. -> It will test whether the individual bits of n are ON or OFF


Question 17.


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(128, 2);
s=fun(128, 16);
printf("%s\n",s);
return 0;
}
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;
}
  1.    It converts a number to a given base.
  2.    It converts a number to its equivalent binary.
  3.    It converts a number to its equivalent hexadecimal.
  4.    It converts a number to its equivalent octal.
 Discuss Question
Answer: Option A. -> It converts a number to a given base.


Question 18.


Which of the following statements are correct about the program?


#include<stdio.h>
int main()
{
unsigned int num;
int c=0;
scanf("%u", &num);
for(;num;num>>=1)
{
if(num & 1)
c++;
}
printf("%d", c);
return 0;
}
  1.    It counts the number of bits that are ON (1) in the number num.
  2.    It counts the number of bits that are OFF (0) in the number num.
  3.    It sets all bits in the number num to 1
  4.    Error
 Discuss Question
Answer: Option A. -> It counts the number of bits that are ON (1) in the number num.

If we give input 4, it will print 1. 
Binary-4 == 00000000 00000100 ; Total number of bits = 1. 
If we give input 3, it will print 2. 
Binary-3 == 00000000 00000011 ; Total number of bits = 2. 
If we give input 511, it will print 9. 
Binary-511 == 00000001 11111111 ; Total number of bits = 9.


Question 19.


What will be the output of the program?


#include<stdio.h>
int main()
{
printf("%d %dn", 32<<1, 32<<0);
printf("%d %dn", 32<<-1, 32<<-0);
printf("%d %dn", 32>>1, 32>>0);
printf("%d %dn", 32>>-1, 32>>-0);
return 0;
}
A. Garbage values
B. 64 32
0 32
16 32
0 32
C. All zeros
D. 8 0
0 0
32 0
0 16
  1.    It prints all even bits from num
  2.    It prints all odd bits from num
  3.    It prints binary equivalent num
  4.    Error
 Discuss Question
Answer: Option C. -> It prints binary equivalent num

Answer: Option (B)


Question 20.


Which of the following statements are correct about the program?


#include<stdio.h>
int main()
{
unsigned int num;
int i;
scanf("%u", &num);
for(i=0; i
  1.    It prints all even bits from num
  2.    It prints all odd bits from num
  3.    It prints binary equivalent num
  4.    Error
 Discuss Question
Answer: Option C. -> It prints binary equivalent num

If we give input 4, it will print 00000000 00000100 ;
If we give input 3, it will print 00000000 00000011 ;
If we give input 511, it will print 00000001 11111111 ;


Latest Videos

Latest Test Papers