1. How many groups of output of operation are there in c++?
a) 1
b) 2
c) 3
d) 4
2. Picl out the correct objects about the instantiation of output stream.
a) cout
b) cerr
c) clog
d) All of the mentioned
3. What is meant by ofstream in c++?
a) Writes to a file
b) Reads from a file
c) Both a & b
d) None of the mentioned
4. What is the output of this program?
a) Steve jobs
b) A
c) 65
d) 65
5. What is the output of this program?
a) 1
b) 2
c) 3
d) 4
2. Picl out the correct objects about the instantiation of output stream.
a) cout
b) cerr
c) clog
d) All of the mentioned
3. What is meant by ofstream in c++?
a) Writes to a file
b) Reads from a file
c) Both a & b
d) None of the mentioned
4. What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
char str[] = "Steve jobs";
int val = 65;
char ch = 'A';
cout.width (5);
cout << right;
cout << val << endl;
return 0;
}
b) A
c) 65
d) 65
5. What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
int n;
n = 43;
cout << hex << n << endl;
return 0;
}
b) 2b
c) 20
d) 50
6. What is the output of this program in the “test.txt” file?
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos = outfile.tellp();
outfile.seekp (pos - 7);
outfile.write (" sam", 4);
outfile.close();
return 0;
}
b) apple
c) sample
d) This is a sample
7. What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
int n;
n = -77;
cout.width(4);
cout << internal << n << endl;
return 0;
}
b) -77
c) – 77
d) None of the mentioned
8. What is the output of this program?
#include <iostream>
#include <locale>
using namespace std;
int main()
{
locale mylocale("");
cout.imbue( mylocale );
cout << (double) 3.14159 << endl;
return 0;
}
b) 3.14159
c) Error
d) None of the mentioned
9. How many types of output stream classes are there in c++?
a) 1
b) 2
c) 3
d) 4
10. What must be specified when we construct an object of class ostream?
a) stream
b) streambuf
c) memory
d) None of the mentioned