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. By default, all the files in C++ are opened in _________ mode.
2. Which header file is used to manipulate the string?
3. What is the benefit of c++ input and output over c input and output?
4. What kind of locale does every program is having in C++?
5. How many objects are used for input and output to a string?
6. What will be the output of the following C++ code?
#include
#include
int main ()
{
char s[] = "365.24 29.53";
char* p;
double d1, d2;
d1 = strtod (s, &p);
d2 = strtod (p, NULL);
printf ("%.2f\n", d1/d2);
return 0;
}
7. With which does the trigonometric functions work with angles in c++?
8. Which constant member functions does not modify the string?
9. Which of the following is used to create a stream that performs both input and output operations?
10. What will the monetary facet will do?
11. What will the max function in the numeric limit will return for type float?
12. What will be the output of the following C++ code?
#include
#include
int main ()
{
int i = 0;
char str[] = "Steve Jobs\n";
char c;
while (str[i])
{
c = str[i];
if (islower(c))
c = toupper(c);
putchar (c);
i++;
}
return 0;
}
13. What is the use of accumulate function in a numeric library?
14. What will be the output of the following C++ code in text files?
#include
int main ()
{
char buffer[BUFSIZ];
FILE *p1, *p2;
p1 = fopen ("myfile.txt", "w");
p2 = fopen ("myfile2.txt", "a");
setbuf ( p1 , buffer );
fputs ("Buffered stream", p1);
fflush (p1);
setbuf ( p2 , NULL );
fputs ("Unbuffered stream", p2);
fclose (p1);
fclose (p2);
return 0;
}
15. Choose the correct formatted code.
16. How many parameters are used in frexp function?
17. Which of the following have their changes in their declaration related to constness of parameter?
18. What will be the output of the following C++ code?
#include
#include
int main ()
{
int param, result;
int n;
param = 8.0;
result = frexp (param , &n);
printf ("%d \n", param);
return 0;
}
19. By using which function does the buffer are automatically flushed?
20. When will the cin can start processing of input?
21. Which mathematics library is used for vector manipulation in c++?
22. Which header file is required for manipulation of math functions in c++?
23. What will be the output of the following C++ code?
#include
#include
using namespace std;
void showDate(int m, int d, int y)
{
cout << setfill('0');
cout << setw(2) << m << '/'
<< setw(2) << d << '/'
<< setw(4) << y << endl;
}
int main()
{
showDate(1, 1, 2013);
return 0;
}
24. How many tests are available in read and write operations?
25. Which of the following mathematical function is overloaded in and ?