Assuming a integer 2-bytes, What will be the output of the program?
#include<stdio.h>
int main()
{
printf("%x\n", -1<<3);
return}
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;
}
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?
Bitwise & and | are unary operators
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}
Which bitwise operator is suitable for checking whether a particular bit is on or off?
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
}
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}
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
}
Bitwise & can be used to check if more than one bit in a number is on.
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)
What will be the output of the program?
#include<stdio.h>
int main()
{
unsigned char i = 0x printf("%d\n", i<<1);
return}
Bitwise & can be used to check if a bit in number is set or not.
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
}
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}