Sizes C++ MCQ

Errorlogger
0
1. The size of an object or a type can be determined using which operator?
a) malloc
b) sizeof
c) malloc
d) calloc

Answer:b


2. It is guaranteed that a ____ has atleast 8bits and a ____ has atleast 16 bits.
a) int, float
b) char, int
c) bool, char
d) char, short

Answer:d


3. Implementation dependent aspects about an implementation can be found in ____
a) <implementation>
b) <limits>
c) <limit>
d) <numeric>

Answer:b


4. Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is ____.
a) char, 1
b) int, 1
c) float, 8
d) char, 4

Answer:a


5. Identify the incorrect option.
a) 1 <= sizeof(bool) <= sizeof(long)
b) sizeof(float) <= sizeof(double) <= sizeof(long double)
c) sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
d) sizeof(N) = sizeof(signed N) = sizeof(unsigned N)

Answer:c


6. What is the output of the following program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int num = 0x20 + 020 + 20;
  6.         cout << sizeof(num)<<'n';
  7.         return 0;
  8.     }
a) 2
b) 4
c) Depends on compiler.
d) garbage

Answer:c


7. What is the output of the following program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main ( )
  4.     {
  5.         static double i;
  6.         i = 20;
  7.         cout << sizeof(i);
  8.         return 0;
  9.     }
a) 4
b) 2
c) 8
d) garbage

Answer:c


8. What is the output of the following program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int num1 = 10;
  6.         float num2 = 20;
  7.         cout << sizeof(num1 + num2);
  8.         return 0;
  9.     }
a) 2
b) 4
c) 8
d) garbage

Answer:b


9. What is the output of the following program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int a = 5;
  6.         float b;
  7.         cout << sizeof(++a + b);
  8.         cout << a;
  9.         return 0;
  10.     }
a) 2 6
b) 4 6
c) 2 5
d) 4 5

Answer:d


10. Arrange the size of the data type from lower to higher value in this program.
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         char y = 'a';
  6.         int x = 10;
  7.         float z = 10.1;
  8.         cout << sizeof(char);
  9.         cout << sizeof(int);
  10.         cout << sizeof(float);
  11.         return 0;
  12.     }
a) float > int < char
b) int < char < float
c) char < int < float
d) none of the mentioned

Answer:c
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !