MCQs
Total Questions : 35
| Page 2 of 4 pages
Answer: Option A. -> True
Answer: Option A. -> True
0001 => 1
0010 => 2
0100 => 4
1000 => 8
Answer: Option A. -> True
Answer: Option A. -> True
Answer: Option B. -> False
Bitwise & and | are not unary operators only bitwise ! is unary operator.
Answer: Option B. -> It will test whether the individual bits of n are ON or OFF
Question 17.
#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;
}
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;
}
Answer: Option A. -> It converts a number to a given base.
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.
Answer: Option C. -> It prints binary equivalent num
Answer: Option (B)
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 ;