Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.


What would be the output of the following program (in 32-bit systems)?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
cout
  1.    1 4 4
  2.    1 4 8
  3.    1 8 8
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 1 4 4

Character is 1 byte, integer 4 bytes and float 4 bytes.


Question 2.


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a = 5;
6.
float b;
7.
cout
  1.    2 6
  2.    4 6
  3.    2 5
  4.    4 5
 Discuss Question
Answer: Option D. -> 4 5

The a as a integer will be converted to float while calculating the size. The value of any variable doesn’t modify inside sizeof operator. Hence value of variable a will remain 5.
Output:
$ g++ size3.cpp
$ a.out
4 5


Question 3.


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int num1 = 10;
6.
float num2 = 20;
7.
cout
  1.    2
  2.    4
  3.    8
  4.    garbage
 Discuss Question
Answer: Option B. -> 4

In this program, integer is converted into float. Therefore the result of num1 and num2 is float. And it 

is returning the size of the float.
Output:
$ g++ size2.cpp
$ a.out
4


Question 4.


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main ( )
4.
{
5.
static double i;
6.
i = 20;
7.
cout
  1.    4
  2.    2
  3.    8
  4.    garbage
 Discuss Question
Answer: Option C. -> 8

The size of the double data type is 8.
$ g++ size1.cpp
$ a.out
8


Question 5.


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int num = 0x20 + 020 + 20;
6.
cout
  1.    2
  2.    4
  3.    Depends on compiler.
  4.    garbage
 Discuss Question
Answer: Option C. -> Depends on compiler.

The sum of three numbers are belongs to different number systems, so the result is typecasted into integer.
Output:
$ g++ size.cpp
$ a.out
4


Question 6.

Identify the incorrect option.


  1.    1
  2.    sizeof(float)
  3.    sizeof(char)
  4.    sizeof(N) = sizeof(signed N) = sizeof(unsigned N)
 Discuss Question
Answer: Option C. -> sizeof(char)

sizeof(char) <= sizeof(wchar_t) <= sizeof(long) 


Question 7.

Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char 

is ____.


  1.    char, 1
  2.    int, 1
  3.    float, 8
  4.    char, 4
 Discuss Question
Answer: Option A. -> char, 1

None.


Question 8.

Implementation dependent aspects about an implementation can be found in ____


 Discuss Question
Answer: Option A. -> char, 1

The limit header holds the details of the machine dependent details.


Question 9.

It is guaranteed that a ____ has atleast 8bits and a ____ has atleast 16 bits.


  1.    int, float
  2.    char, int
  3.    bool, char
  4.    char, short
 Discuss Question
Answer: Option D. -> char, short

None.


Question 10.

The size of an object or a type can be determined using which operator?


  1.    malloc
  2.    sizeof
  3.    malloc
  4.    calloc
 Discuss Question
Answer: Option B. -> sizeof

The sizeof operator gives the size of the object or type.


Latest Videos

Latest Test Papers