Computer Science, asked by jayxsingh, 10 months ago

void main()
{ char ch = 'A' ;
fstream fileout("data.dat", ios :: app) ;
fileout <<ch;
int p = fileout.tellg();
cout <<p;

Q.What is the output if the file content before the execution of the program is the string "ABC"
(Note that " " are not part of the file).
[CBSE OD 06]
Ans. 4

I need an explanation on how to get this output. ​

Answers

Answered by aartisahu68
1

Answer:

you got the answer 4. ok

Explanation:

as the append function is used in the program which means it displays the output after the one that is already showing on the console screen ,

also tellg() function tells the current position of the pointer,

as ABC is already printed on screen , the position of pointer is 3 after printing the character A it will become 4

Similar questions