Home > C++ Programming > Quizzes > C++ Programming Practice Test: Strings, Streams & Numerics in C++
C++ Programming Practice Test: Strings, Streams & Numerics in C++
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 100% Most missed: “What must be specified when we construct an object of class ostream?”
C++ quiz on basic strings and their characters, I/O streams, file and string streams, standard library and mathematical applications like numeric limits, file handling, vector arithmetic and random numbers. Strings: A string in C++ is a sequence of characters. It is a data type that is used to store text. Strings are declared using the string keyword.  Strings can be concatenated using the + operator.  Strings can be compared using the ==, !=, , = operators.  Streams: A stream in C++ is a sequence of characters that can be read from or written to. Streams are used to input and output... Show more
C++ Programming Practice Test: Strings, Streams & Numerics in C++
Time left 00:00
25 Questions

1. When will the cin can start processing of input?
2. What can be used to input a string with blank space?
3. What must be specified when we construct an object of class ostream?
4. What type of reference should be used in vector arithmetic?
5. Where does a cin stops it extraction of data?
6. Which is an instantiation of the basic_string class template?
7. What will be the output of the following C++ code by manipulating the text file?
#include
int main ()
{
if (remove( "myfile.txt" ) != 0 )
perror( "Error" );
else
puts( "Success" );
return 0;
}
8. To which type does the numeric limits are suitable?
9. How many parameters are available in partial_sum function in c++?
10. What will be the output of the following C++ code?
#include
using namespace std;
class vec
{
public:
vec(float f1, float f2)
{
x = f1;
y = f2;
}
vec()
{
}
float x;
float y;
};
vec addvectors(vec v1, vec v2);
int main()
{
vec v1(3, 6);
vec v2(2, -2);
vec v3 = addvectors(v1, v2);
cout << v3.x << ", " << v3.y << endl;
}
vec addvectors(vec v1, vec v2)
{
vec result;
result.x = v1.x + v2.x;
result.y = v1.y + v2.y;
return result;
};
11. What will act as a intermediate between i/o operations and physical file?
12. How many parameters are available in srand function?
13. Which function is used to position back from the end of file object?
14. Where does the member should be defined if it is used in the program?
15. Which header file is used for the numeric limits in C++?
16. What will be the output of the following C++ code?
#include
#include
using namespace std;
int main ()
{
string str;
string str2="Steve jobs";
string str3="He founded apple";
str.append(str2);
str.append(str3, 6, 3);
str.append(str3.begin() + 6, str3.end());
str.append(5,
0x2e);
cout << str << '\n';
return 0;
}
17. Which header file is required for manipulation of math functions in c++?
18. Which mathematics library is used for vector manipulation in c++?
19. Pick out the correct syntax of the header file that can be used with C++.
20. What will happen if a string is empty?
21. What will the monetary facet will do?
22. Which objects information is loaded in locale object?
23. What can be improved by formatting the source code?
24. What is the main feature of locale in C++?
25. Which operator is used for input stream?