Question: 4. Write a fragment of code that counts the number of words in each line of an input le. Ir Declare and open the le

 4. Write a fragment of code that counts the number of

4. Write a fragment of code that counts the number of words in each line of an input le. Ir Declare and open the le (\"song . txt") I Declare an}.r other variables you need to accomplish this task Ir Displayr the line number and the number of words on that line II Close the le. Example lithe input le contains the following text: Row, row, row your boat, Gently down the stream. Merrily, merrily, merrily, merrily, life is but a dream. The output is: line 1: 5 words line 2: words line 3: words line : 5 words

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!