#include &lt;iostream&gt;    #include &lt;fstream&gt;    using namespace std;    int main &#40;&#41;     &#123;        int length;        char * buffer;        ifstream is;        is.open &#40;&quot;sample.txt&quot;, ios :: binary &#41;;        is.seekg &#40;0, ios :: end&#41;;        length = is.tellg&#40;&#41;;        is.seekg &#40;0, ios :: beg&#41;;        buffer = new char &#91;length&#93;;        is.read &#40;buffer, length&#41;;        is.close&#40;&#41;;        cout.write &#40;buffer, length&#41;;        delete&#91;&#93; buffer;        return 0;    &#125;
A. This is sample
B. sample
C. Error
D. Runtime error
Answer:A
#include &lt;iostream&gt;    #include &lt;fstream&gt;    using namespace std;    int main &#40;&#41;     &#123;        int length;        char * buffer;        ifstream is;        is.open &#40;&quot;sample.txt&quot;, ios :: binary &#41;;        is.seekg &#40;0, ios :: end&#41;;        length = is.tellg&#40;&#41;;        is.seekg &#40;0, ios :: beg&#41;;        buffer = new char &#91;length&#93;;        is.read &#40;buffer, length&#41;;        is.close&#40;&#41;;        cout.write &#40;buffer, length&#41;;        delete&#91;&#93; buffer;        return 0;    &#125;
A. This is sample B. sample C. Error D. Runtime error
Explanation:In this program, if the file exist, it will read the file. Otherwise it will throw an exception. A runtime error will occur because the value of the length variable will be “-1” if file doesn’t exist and in line 13 we are trying to allocate an array of size “-1”.