1. The size_t integer type in C++ is?
a) Unsigned integer of at least 64 bits
b) Signed integer of at least 16 bits
c) Unsigned integer of at least 16 bits
d) Signed integer of at least 64 bits
2. What is the output of the following program?
a) x is greater
b) y is greater
c) Implementation defined
d) Arbitrary
3. Which of these expressions will return true if the input integer v is a power of two?
a) (v | (v + 1)) == 0;
b) (v & (v – 1)) == 0;
c) (v | (v + 1)) == 0;
d) (v & (v – 1)) == 0;
4. What is the value of the following 8-bit integer after all statements are executed?
int x = 1;
x = x << 7;
x = x >> 7;
a) 1
b) -1
c) 127
d) Implementation defined
5. Which of these expressions will make the rightmost set bit zero in an input integer x?
a) x = x | (x-1)
b) x = x & (x-1)
c) x = x | (x+1)
d) x = x & (x+1)
6. Which of these expressions will isolate the rightmost set bit?
a) x = x & (~x)
b) x = x ^ (~x)
c) x = x & (-x)
d) x = x ^ (-x)
7. 0946, 786427373824, ‘x’ and 0X2f are _____, _____, ____ and _____ literals respectively
a) decimal, character,octal, hexadecimal
b) octal, hexadecimal, character, decimal
c) hexadecimal, octal, decimal, character
d) octal, decimal, character, hexadecimal
8. What will be the output of this program?
a) ANDing integer ‘a’ with ‘true’ :8
b) ANDing integer ‘a’ with ‘true’ :0
c) ANDing integer ‘a’ with ‘true’ :1
d) None of the mentioned
9. What will be output of this program?
a) compile time error
b) -1 1
c) 1 -1
d) implementation defined
10. What will be output of this function?
a) 0
b) 1
c) Compiler error may be possible
d) Runtime error may be possible
a) Unsigned integer of at least 64 bits
b) Signed integer of at least 16 bits
c) Unsigned integer of at least 16 bits
d) Signed integer of at least 64 bits
Answer:c
2. What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int x = -1;
unsigned int y = 2;
if(x > y) {
cout << "x is greater";
} else {
cout << "y is greater";
}
}
b) y is greater
c) Implementation defined
d) Arbitrary
Answer:a
3. Which of these expressions will return true if the input integer v is a power of two?
a) (v | (v + 1)) == 0;
b) (v & (v – 1)) == 0;
c) (v | (v + 1)) == 0;
d) (v & (v – 1)) == 0;
Answer:d
4. What is the value of the following 8-bit integer after all statements are executed?
int x = 1;
x = x << 7;
x = x >> 7;
a) 1
b) -1
c) 127
d) Implementation defined
Answer:d
5. Which of these expressions will make the rightmost set bit zero in an input integer x?
a) x = x | (x-1)
b) x = x & (x-1)
c) x = x | (x+1)
d) x = x & (x+1)
Answer:b
6. Which of these expressions will isolate the rightmost set bit?
a) x = x & (~x)
b) x = x ^ (~x)
c) x = x & (-x)
d) x = x ^ (-x)
Answer:c
7. 0946, 786427373824, ‘x’ and 0X2f are _____, _____, ____ and _____ literals respectively
a) decimal, character,octal, hexadecimal
b) octal, hexadecimal, character, decimal
c) hexadecimal, octal, decimal, character
d) octal, decimal, character, hexadecimal
Answer:d
8. What will be the output of this program?
#include <iostream>
using namespace std;
int main()
{
int a = 8;
cout << "ANDing integer 'a' with 'true' :" << a && true;
return 0;
}
b) ANDing integer ‘a’ with ‘true’ :0
c) ANDing integer ‘a’ with ‘true’ :1
d) None of the mentioned
Answer:a
9. What will be output of this program?
#include <iostream>
using namespace std;
int main()
{
int i = 3;
int l = i / -2;
int k = i % -2;
cout << l << k;
return 0;
}
b) -1 1
c) 1 -1
d) implementation defined
Answer:b
10. What will be output of this function?
int main()
{
register int i = 1;
int *ptr = &i;
cout << *ptr;
return 0;
}
b) 1
c) Compiler error may be possible
d) Runtime error may be possible
Answer:c