C++ cin, cout Aptitude Questions and Answers

C++ cin, cout Aptitude: This section contains C++ cin, cout aptitude questions and answers with explanations.
Submitted by Nidhi, on February 17, 2021

1) Which of the following is known as the insertion operator in C++?

  1. <<
  2. >>
  3. ~
  4. ^^

2) Which of the following is known as exertion operator in C++?

  1. <<
  2. >>
  3. ~
  4. ^^

3) There are the following statements that are below, which of them are correct about “endl” in C++?

  1. The "endl" is a manipulator in C++.
  2. The "endl" is used to print a new line on the standard output device.
  3. The "endl" is used to flush the output stream.
  4. The "endl" is a predefined structure.

Options:

  1. A and B
  2. B and C
  3. A, B, and C
  4. A, B, C, and D

4) In C++, the cin and cout are?

  1. Predefined objects
  2. Predefined pointers
  3. Operators
  4. Keywords

5) The insertion and exertion operators are overloaded in predefined "iostream" class?

  1. Yes
  2. No

6) What is the correct output of the given code snippets?

#include <iostream>

int main()
{
   std::cout<<"Hello world";
   return 0;
}

Options:

  1. Compilation error
  2. Hello world
  3. Runtime Error
  4. Linker error

7) What is the correct output of the given code snippets?

#include <iostream>

int main()
{
   cout>>"ABC" <<" " <<"XYZ";
   return 0;
}

Options:

  1. Compilation error
  2. ABC XYX
  3. Runtime Error
  4. Linker error

8) What is the correct output of the given code snippets?

#include <iostream>
using namespace std;

int main()
{
   cout<<("ABC")<<(" ")<<("XYZ");
   return 0;
}

Options:

  1. Compilation error
  2. ABC XYX
  3. Runtime Error
  4. Linker error

9) What is the correct output of the given code snippets?

#include <iostream>
using namespace std;

int main()
{
   cout<<("ABC"<<" "<<"XYZ");
   return 0;
}

Options:

  1. Compilation error
  2. Hello world
  3. Runtime Error
  4. Linker error

10) What is the correct output of the given code snippets?

#include <iostream>
using namespace std;

int main()
{
   int ret = 0;
   
   ret = cout<<"ABC";
   
   cout<<"ret: "<<ret;
   
   return 0;
}

Options:

  1. Compilation error
  2. Hello world
  3. Runtime Error
  4. Linker error

11) What is the correct output of the given code snippets?

#include <iostream>
using namespace std;

int main()
{
   cout.operator<<("hello");
   return 0;
}

Options:

  1. hello
  2. A hexadecimal address
  3. Runtime Error
  4. Linker error

12) What is the correct output of the given code snippets?

#include <iostream>
using namespace std;

int main()
{
   cout.operator<string><<("hello");
   return 0;
}

Options:

  1. hello
  2. Compiler error
  3. Runtime Error
  4. Linker error





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.