[Type B] File Handling – Chapter 5 Sumita Arora

|
Table of Contents

2. If the file ‘poemBTH.txt‘ contains the following poem (by Paramhansa Yogananda), then what outputs will be produced by both the code fragments given in Q1.

Answer: Code (a):

God made the Earth;
Man made confusing countries
And their fancy-frozen boundaries.
But with unfound boundless Love
I behold the borderland of my India
Expanding into the world.
Hail, mother of religions, lotus, scenic beauty, and sages!

Code (b):

God made the Earth;
Man made confusing co

Explanation:

As explained in Q1, code (a) reads the entire file, resulting in the complete poem as output. Code (b) reads only the first 100 characters, including the first line and part of the second line.

"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *

One Comment