1. The size of an object or a type can be determined using which operator?
a) malloc
b) sizeof
c) malloc
d) calloc
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
3. Implementation dependent aspects about an implementation can be found in ____
a) <implementation>
b) <limits>
c) <limit>
d) <numeric>
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
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)
6. What is the output of the following program?
a) 2
b) 4
c) Depends on compiler.
d) garbage
7. What is the output of the following program?
a) 4
b) 2
c) 8
d) garbage
8. What is the output of the following program?
a) 2
b) 4
c) 8
d) garbage
9. What is the output of the following program?
a) 2 6
b) 4 6
c) 2 5
d) 4 5
10. Arrange the size of the data type from lower to higher value in this program.
a) float > int < char
b) int < char < float
c) char < int < float
d) none of the mentioned
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?
#include <iostream>
using namespace std;
int main()
{
int num = 0x20 + 020 + 20;
cout << sizeof(num)<<'n';
return 0;
}
b) 4
c) Depends on compiler.
d) garbage
Answer:c
7. What is the output of the following program?
#include <iostream>
using namespace std;
int main ( )
{
static double i;
i = 20;
cout << sizeof(i);
return 0;
}
b) 2
c) 8
d) garbage
Answer:c
8. What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int num1 = 10;
float num2 = 20;
cout << sizeof(num1 + num2);
return 0;
}
b) 4
c) 8
d) garbage
Answer:b
9. What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int a = 5;
float b;
cout << sizeof(++a + b);
cout << a;
return 0;
}
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.
#include <iostream>
using namespace std;
int main()
{
char y = 'a';
int x = 10;
float z = 10.1;
cout << sizeof(char);
cout << sizeof(int);
cout << sizeof(float);
return 0;
}
b) int < char < float
c) char < int < float
d) none of the mentioned
Answer:c