Basic Input/Output


  1. What is the output of this program?
    #include <iostream>
    #include >locale<
    using namespace std;
    int main()
    {
    locale NewLocale("");
    cout.imbue( NewLocale );
    cout << (double) 6.1250024 << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    In this program, We are using the locale and then assigning the type to the value.


  1. What is the output of this program in the “Example.txt” file?
    #include <fstream>
    using namespace std;
    int main ()
    {
    long pos;
    ofstream outfile;
    outfile.open ("Example.txt");
    outfile.write ("This is a Sample",16);
    pos = outfile.tellp();
    outfile.seekp (pos - 7);
    outfile.write (" Ex", 6);
    outfile.close();
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are changing the ap to sam by using the pos function.



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main ()
    {
    int num;
    num = -25;
    cout.width(4);
    cout << internal << num << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, We are using the internal function and moving the 25 to one position.


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main ()
    {
    int num;
    num = 45;
    cout << hex << num << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    In this program, We are printing the hexadecimal value of the given decimal number by using hex function.



  1. How many types of output stream classes are there in c++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    There are three output stream classes in c++. They are ostream, ofstream and ostrstream.