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
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
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
Explanation: In sequence point, the overloaded operators behave like a function.
4. What do input and output objects support?
a) Terminated sequences
b) Extracted sequences
c) Null-terminated sequences
d) Terminated & Extracted sequences
View Answer
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
Explanation: To resolve all the side-effects in the program, the sequence point should not be overlapped.
6. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mys;
char mya[20]= "Hello world";
mys = mya;
cout << mys << '\n';
return 0;
}
a) Hello world
b) Hello
c) Error
d) Runtime error
View Answer
Explanation: In this program, We converted the char values into the string.
Output:
$ g++ sts.cpp $ a.out Hello world
7. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool IsOdd (int i)
{
return (i % 2) == 1;
}
int main ()
{
vector<int> myvector;
for (int i = 1; i < 10; ++i) myvector.push_back(i);
vector<int> :: iterator bound;
bound = partition (myvector.begin(), myvector.end(), IsOdd);
for (vector<int> :: iterator it = myvector.begin(); it != bound; ++it)
cout << ' ' << *it;
return 0;
}
a) 1 3 5
b) 1 3 9
c) 1 9 3 7
d) 1 9 3 7 5
View Answer
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
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.
- Apply for C++ Internship
- Practice Programming MCQs
- Check Programming Books
- Check Computer Science Books
- Apply for Computer Science Internship