SlideShare a Scribd company logo
7.4 LAB: Counting chars, words, and lines ir Write a program that asks the user for a file name
and prints the number of characters, words, and lines in that file. Ex: If the input file contains:
Mary had a little lamb Whose fleece was white as snow. And everywhere that Mary went, The
lamb was sure to go! the output is: The file contains 110 characters, 22 words and 4 lines You
will need to prompt the user for the input file name and then use a for loop to traverse the file.
Use Sections 7.2.2 and 7.2.3 in your textbook for reference.

More Related Content

More from aimscomputers1

8- Which of the following statements are FALSE about the phylum Chorda.pdf
8- Which of the following statements are FALSE about the phylum Chorda.pdf8- Which of the following statements are FALSE about the phylum Chorda.pdf
8- Which of the following statements are FALSE about the phylum Chorda.pdf
aimscomputers1
 
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
aimscomputers1
 

More from aimscomputers1 (20)

7- When doing Tissue Culture- it is essential that you understand how.pdf
7- When doing Tissue Culture- it is essential that you understand how.pdf7- When doing Tissue Culture- it is essential that you understand how.pdf
7- When doing Tissue Culture- it is essential that you understand how.pdf
 
7- What is the difference between blood group antigens and blood group.pdf
7- What is the difference between blood group antigens and blood group.pdf7- What is the difference between blood group antigens and blood group.pdf
7- What is the difference between blood group antigens and blood group.pdf
 
7- To begin understanding the underlying pulmonary disorder- complete.pdf
7- To begin understanding the underlying pulmonary disorder- complete.pdf7- To begin understanding the underlying pulmonary disorder- complete.pdf
7- To begin understanding the underlying pulmonary disorder- complete.pdf
 
7- What is the Windows Media Creation Tool- What method did you use to.pdf
7- What is the Windows Media Creation Tool- What method did you use to.pdf7- What is the Windows Media Creation Tool- What method did you use to.pdf
7- What is the Windows Media Creation Tool- What method did you use to.pdf
 
7- The services and functions provided by an operating system can be d.pdf
7- The services and functions provided by an operating system can be d.pdf7- The services and functions provided by an operating system can be d.pdf
7- The services and functions provided by an operating system can be d.pdf
 
7- The lone-run seeregatn supply curve and short-run adjustments The f.pdf
7- The lone-run seeregatn supply curve and short-run adjustments The f.pdf7- The lone-run seeregatn supply curve and short-run adjustments The f.pdf
7- The lone-run seeregatn supply curve and short-run adjustments The f.pdf
 
72- of all Americans live in cities with population greater than 100-0.pdf
72- of all Americans live in cities with population greater than 100-0.pdf72- of all Americans live in cities with population greater than 100-0.pdf
72- of all Americans live in cities with population greater than 100-0.pdf
 
70-calcium ions (Ca2+) are found in their highest concentration in ex.pdf
70-calcium ions (Ca2+)  are found in their highest concentration in ex.pdf70-calcium ions (Ca2+)  are found in their highest concentration in ex.pdf
70-calcium ions (Ca2+) are found in their highest concentration in ex.pdf
 
7-8-9) Sketch two neighboring pepper cells very carefully- This sketch.pdf
7-8-9) Sketch two neighboring pepper cells very carefully- This sketch.pdf7-8-9) Sketch two neighboring pepper cells very carefully- This sketch.pdf
7-8-9) Sketch two neighboring pepper cells very carefully- This sketch.pdf
 
7- Suppose utility of an individual is U-min-X-Y-- Price of X(Px) is 2.pdf
7- Suppose utility of an individual is U-min-X-Y-- Price of X(Px) is 2.pdf7- Suppose utility of an individual is U-min-X-Y-- Price of X(Px) is 2.pdf
7- Suppose utility of an individual is U-min-X-Y-- Price of X(Px) is 2.pdf
 
7- Which of the following units is youngest- A- H- I- M- K 8- Which of.pdf
7- Which of the following units is youngest- A- H- I- M- K 8- Which of.pdf7- Which of the following units is youngest- A- H- I- M- K 8- Which of.pdf
7- Which of the following units is youngest- A- H- I- M- K 8- Which of.pdf
 
7- Sharron Roberts- a financial analyst in his organization- recently.pdf
7- Sharron Roberts- a financial analyst in his organization- recently.pdf7- Sharron Roberts- a financial analyst in his organization- recently.pdf
7- Sharron Roberts- a financial analyst in his organization- recently.pdf
 
7- Which observation led Wallace to conclude that all species are conn.pdf
7- Which observation led Wallace to conclude that all species are conn.pdf7- Which observation led Wallace to conclude that all species are conn.pdf
7- Which observation led Wallace to conclude that all species are conn.pdf
 
8-1- Why is preferred stock referred to as a hybrid security- It is of.pdf
8-1- Why is preferred stock referred to as a hybrid security- It is of.pdf8-1- Why is preferred stock referred to as a hybrid security- It is of.pdf
8-1- Why is preferred stock referred to as a hybrid security- It is of.pdf
 
8- Which of the following statements are FALSE about the phylum Chorda.pdf
8- Which of the following statements are FALSE about the phylum Chorda.pdf8- Which of the following statements are FALSE about the phylum Chorda.pdf
8- Which of the following statements are FALSE about the phylum Chorda.pdf
 
8- What is one SDOH mentioned in Cam Juarez's talk- What health inequi.pdf
8- What is one SDOH mentioned in Cam Juarez's talk- What health inequi.pdf8- What is one SDOH mentioned in Cam Juarez's talk- What health inequi.pdf
8- What is one SDOH mentioned in Cam Juarez's talk- What health inequi.pdf
 
7- Viruses use receptor-mediated endocytosis to enter the cells of wha.pdf
7- Viruses use receptor-mediated endocytosis to enter the cells of wha.pdf7- Viruses use receptor-mediated endocytosis to enter the cells of wha.pdf
7- Viruses use receptor-mediated endocytosis to enter the cells of wha.pdf
 
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
8- Which of the following is a true statement- A- Myelin and acetyleho.pdf
 
8- What does the following command sequence do- ofstream oFile- oFile-.pdf
8- What does the following command sequence do- ofstream oFile- oFile-.pdf8- What does the following command sequence do- ofstream oFile- oFile-.pdf
8- What does the following command sequence do- ofstream oFile- oFile-.pdf
 
7- We can determine the motions of objects towards or away from us usi.pdf
7- We can determine the motions of objects towards or away from us usi.pdf7- We can determine the motions of objects towards or away from us usi.pdf
7- We can determine the motions of objects towards or away from us usi.pdf
 

Recently uploaded

Recently uploaded (20)

Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 

7-4 LAB- Counting chars- words- and lines ir Write a program that asks.pdf

  • 1. 7.4 LAB: Counting chars, words, and lines ir Write a program that asks the user for a file name and prints the number of characters, words, and lines in that file. Ex: If the input file contains: Mary had a little lamb Whose fleece was white as snow. And everywhere that Mary went, The lamb was sure to go! the output is: The file contains 110 characters, 22 words and 4 lines You will need to prompt the user for the input file name and then use a for loop to traverse the file. Use Sections 7.2.2 and 7.2.3 in your textbook for reference.