Input Stream C++ MCQ

Errorlogger
0
1. Which operator is used for input stream?
a) >
b) >>
c) <
d) <<



2. Where does a cin stops it extraction of data?
a) By seeing a blankspace
b) By seeing (
c) Both a & b
d) None of the mentioned



3. Which is used to get the input during runtime?
a) cout
b) cin
c) coi
d) None of the mentioned



4. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         int i;
  6.         cout << "Please enter an integer value: ";
  7.         cin >> i + 4;
  8.         return 0;
  9.     }
a) 73
b) your value + 4
c) Error
d) None of the mentioned



5. What is the output of this program?
  1.     #include <iostream>
  2.     #include <string>
  3.     #include <sstream>
  4.     using namespace std;
  5.     int main ()
  6.     {
  7.         string mystr;
  8.         float price = 0;
  9.         int quantity = 0;
  10.         cout << "Enter price: ";
  11.         getline (cin, mystr);
  12.         stringstream(mystr) >> price;
  13.         cout << "Enter quantity: ";
  14.         getline (cin, mystr);
  15.         stringstream(mystr) >> quantity;
  16.         cout << "Total price: " << price * quantity << endl;
  17.         return 0;
  18.     }
a) 50
b) Depends on value you enter
c) Error
d) None of the mentioned



6. What is the output of this program?
  1.     #include <iostream>
  2.     #include <ios>
  3.     #include <istream>
  4.     #include <limits>
  5.     using namespace std;
  6.     template <typename CharT>
  7.     void ignore_line ( basic_istream<CharT>& in )
  8.     {
  9.         in.ignore ( numeric_limits<streamsize> :: max(), in.widen ( '\n' ) );
  10.     }
  11.     int main()
  12.     {
  13.         cout << "First input: ";
  14.         cin.get();
  15.         cout << "Clearing cin.\n";
  16.         cin.clear();
  17.         ignore_line ( cin );
  18.         cout << "All done.\n";
  19.     }
a) First input
b) Clearing cin
c) Error
d) None of the mentioned



7. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main( )
  4.     {
  5.         char line[100];
  6.         cin.getline( line, 100, 't' );
  7.         cout << line;
  8.         return 0;
  9.     }
a) 100
b) t
c) It will print what we give.
d) None of the mentioned



8. How many parameters are there in getline function?
a) 1
b) 2
c) 3
d) 4



9. What can be used to input a string with blankspace?
a) inline
b) getline
c) putline
d) None of the mentioned



10. When will the cin can start proceessing of input?
a) After pressing return key
b) BY pressing blankspace
c) Both a & b
d) None of the mentioned

Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !