1. Which operator is used to insert the data into file?
a) >>
b) <<
c) <
d) None of the mentioned
2. Which function is used to position back from the end of file object?
a) seekg
b) seekp
c) Both a & b
d) None of the mentioned
3. How many number of objects are used for input and output to a string?
a) 1
b) 2
c) 3
d) 4
4. What is the output of this program?
a) This is sample
b) sample
c) Error
d) Runtime error
5. What is the output of this program?
a) first
b) second
c) Returns first 2 letter or number from the entered word
d) None of the mentioned
6. What is the output of this program?
a) Done
b) Error
c) Runtime error
d) None of the mentioned
7. What is the output of this program?
a) 100
b) 3.14
c) 314
d) All of the mentioned
8. By seeing which operator thus this program stops getting the input?
a) dot operator
b) insertion operator
c) $ symbol
d) None of the mentioned
9. Which member function is used to determine whether the stream object is currently associated with a file?
a) is_open
b) buf
c) string
d) None of the mentioned
10. Which header file is used for reading and writing to a file?
a) #include<iostream>
b) #include<fstream>
c) #include<file>
d) None of the mentioned
a) >>
b) <<
c) <
d) None of the mentioned
2. Which function is used to position back from the end of file object?
a) seekg
b) seekp
c) Both a & b
d) None of the mentioned
3. How many number of objects are used for input and output to a string?
a) 1
b) 2
c) 3
d) 4
4. What is the output of this program?
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
int length;
char * buffer;
ifstream is;
is.open ("sample.txt", ios :: binary );
is.seekg (0, ios :: end);
length = is.tellg();
is.seekg (0, ios :: beg);
buffer = new char [length];
is.read (buffer, length);
is.close();
cout.write (buffer, length);
delete[] buffer;
return 0;
}
b) sample
c) Error
d) Runtime error
5. What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
char first, second;
cout << "Enter a word: ";
first = cin.get();
cin.sync();
second = cin.get();
cout << first << endl;
cout << second << endl;
return 0;
}
b) second
c) Returns first 2 letter or number from the entered word
d) None of the mentioned
6. What is the output of this program?
#include<iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream outfile ("test.txt");
for (int n = 0; n < 100; n++)
{
outfile << n;
outfile.flush();
}
cout << "Done";
outfile.close();
return 0;
}
b) Error
c) Runtime error
d) None of the mentioned
7. What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
int a = 100;
double b = 3.14;
cout << a;
cout << endl;
cout << b << endl << a * b;
endl (cout);
return 0;
}
b) 3.14
c) 314
d) All of the mentioned
8. By seeing which operator thus this program stops getting the input?
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
char ch;
streambuf * p;
ofstream os ("test.txt");
pbuf = os.rdbuf();
do {
ch = cin.get();
p -> sputc(ch);
} while (ch != '.');
os.close();
return 0;
}
b) insertion operator
c) $ symbol
d) None of the mentioned
9. Which member function is used to determine whether the stream object is currently associated with a file?
a) is_open
b) buf
c) string
d) None of the mentioned
10. Which header file is used for reading and writing to a file?
a) #include<iostream>
b) #include<fstream>
c) #include<file>
d) None of the mentioned