C++ Programming MCQ – Stored Sequences

This section on online C++ test focuses on “Stored Sequences”. One shall practice these test questions to improve their C++ programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C++ programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our online C++ test questions come with detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of C++ questions on “Stored Sequences” along with answers, explanations and/or solutions:

1. What is meant by sequence point?
a) Represent the point of execution in the program
b) Represent the whole program
c) Represent the beginning of the program
d) Represent the end of the program
View Answer

Answer: a
Explanation: A sequence point defines any point in a computer program’s execution at which it is guaranteed that all side effects of previous evaluations have been performed.

2. Pick out the correct statement about sequence point.
a) Sequence point will compile the program
b) Sequence point will resolve all the side effects
c) Sequence point will save the program for execution
d) Sequence point will delete the program for execution
View Answer

Answer: b
Explanation: Sequence point is a point in time at which the dust has settled and all side effects which have been seen so far are guaranteed to be complete.

3. In sequence point, how will the overloaded operators behave like?
a) Function
b) Objects
c) Instance variable
d) Container
View Answer

Answer: a
Explanation: In sequence point, the overloaded operators behave like a function.
advertisement
advertisement

4. What do input and output objects support?
a) Terminated sequences
b) Extracted sequences
c) Null-terminated sequences
d) Terminated & Extracted sequences
View Answer

Answer: c
Explanation: cin and cout support null-terminated sequences as valid containers for sequences of characters.

5. What kind of execution does sequence point allow?
a) Non-overlap
b) Overlap
c) Concurrent
d) Sequence
View Answer

Answer: a
Explanation: To resolve all the side-effects in the program, the sequence point should not be overlapped.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What will be the output of the following C++ code?

  1.     #include <iostream>
  2.     #include <string>
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         string mys;
  7.         char mya[20]= "Hello world";
  8.         mys = mya;
  9.         cout << mys << '\n';
  10.         return 0;
  11.     }

a) Hello world
b) Hello
c) Error
d) Runtime error
View Answer

Answer: a
Explanation: In this program, We converted the char values into the string.
Output:

advertisement
$ g++ sts.cpp
$ a.out
Hello world

7. What will be the output of the following C++ code?

advertisement
  1.     #include <iostream>
  2.     #include <algorithm>
  3.     #include <vector>
  4.     using namespace std;
  5.     bool IsOdd (int i) 
  6.     {
  7.         return (i % 2) == 1; 
  8.     }
  9.     int main () 
  10.     {
  11.         vector<int> myvector;
  12.         for (int i = 1; i < 10; ++i) myvector.push_back(i);
  13.         vector<int> :: iterator bound;
  14.         bound = partition (myvector.begin(), myvector.end(), IsOdd);
  15.         for (vector<int> :: iterator it = myvector.begin(); it != bound; ++it)
  16.             cout << ' ' << *it;
  17.         return 0;
  18.     }

a) 1 3 5
b) 1 3 9
c) 1 9 3 7
d) 1 9 3 7 5
View Answer

Answer: d
Explanation: In this program, We are finding the odd values in the sequence.
Output:

$ g++ sts1.cpp
$ a.out
1 9 3 7 5

8. When does the next sequence point start?
a) At the beginning
b) After a terminating semicolon
c) It is a beginning statement
d) At the end
View Answer

Answer: b
Explanation: After a terminating semicolon the next sequence point start.

Sanfoundry Global Education & Learning Series – C++ Programming Language.

To practice all areas of C++ language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.