Home » C++ Programming » Files and Streams » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main ()
    {
    char First_ch, Second_ch, Third_ch;
    cout << "Enter any word or number: ";
    First_ch = cin.get();
    cin.sync();
    Second_ch = cin.get();
    cin.sync();
    Third_ch = cin.get();
    cout << First_ch << endl;
    cout << Second_ch << endl;
    cout << Third_ch << endl;
    return 0;
    }
    1. Third
    2. Second
    3. First
    4. Returns first 3 letter or number from the entered word
    5. None of these
Correct Option: D

In this program, We are using the sync function to return the first three letters of the entered word.



Your comments will be displayed only after manual approval.