Datatypes in C++ MCQs Exercise I

Ques 1 Datatypes


Which of the following datatypes is in C++ but not in C?

A int
B float
C char
D byte

Ques 2 Datatypes


What is the output of following code?


int main()
{
    int p;
    bool a = false;
    bool b = true;
    int x = 10;
    int y = 5;
    p = ((x | y) + (a + b));
    cout << p;
    return 0;
}

A 14
B 15
C 16
D 17

Ques 3 Datatypes


What is the output of following code?


int main()
{
    int x = 7;
    float y;
    cout << sizeof(++x + y);
    cout << x;
    return 0;
}

A 25
B 45
C 46
D 47

Ques 4 Datatypes


What is the output of following code?


int main()
{
  int a = 6;
  auto check = [=]() 
  {
      a = 11;
  };
  check();
  cout<<"Value of a: "<<a<<endl;
  return 0;
}

A Value of a :5
B Value of a:10
C Segmentation fault
D Error

Ques 5 Datatypes


What is the output of following code?


int main ()
{
   std::string str ("Smallcode.");
   str.back() = '$';
   std::cout << str << endl;
   return 0;
}

A Smallcode$
B Smallcode$.
C Smallcode,$
D Smallcode