SlideShare a Scribd company logo
1 of 1
Download to read offline
Write an if statement to halt program if the program fails to opne a file. Assuem the file to be
opened has name "stats.dat".
Solution
C++ program
#include
#include
using namespace std;
int main () {
ifstream infile;
infile.open ("stats.dat");
if (infile.is_open())
{
while (infile.good())
cout << "file opened successfully" << endl;
infile.close();
}
else
{
cout << "Error opening file";
}
return 0;
}

More Related Content

More from leventhalbrad49439

The Antoine equation often is used to describe vapor pressures lnP .pdf
The Antoine equation often is used to describe vapor pressures lnP .pdfThe Antoine equation often is used to describe vapor pressures lnP .pdf
The Antoine equation often is used to describe vapor pressures lnP .pdfleventhalbrad49439
 
The converson of the English to Christianity began a rich period of .pdf
The converson of the English to Christianity began a rich period of .pdfThe converson of the English to Christianity began a rich period of .pdf
The converson of the English to Christianity began a rich period of .pdfleventhalbrad49439
 
Table 19. Highest Level of Type of organization germ layers .pdf
Table 19. Highest Level of Type of organization germ layers .pdfTable 19. Highest Level of Type of organization germ layers .pdf
Table 19. Highest Level of Type of organization germ layers .pdfleventhalbrad49439
 
Question 12 (5 points)The reason that mitosis can result in the pr.pdf
Question 12 (5 points)The reason that mitosis can result in the pr.pdfQuestion 12 (5 points)The reason that mitosis can result in the pr.pdf
Question 12 (5 points)The reason that mitosis can result in the pr.pdfleventhalbrad49439
 
peripheral circuit functions built-in to the HC12 microcontroller, t.pdf
peripheral circuit functions built-in to the HC12 microcontroller, t.pdfperipheral circuit functions built-in to the HC12 microcontroller, t.pdf
peripheral circuit functions built-in to the HC12 microcontroller, t.pdfleventhalbrad49439
 
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdf
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdfMendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdf
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdfleventhalbrad49439
 
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdf
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdfIf the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdf
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdfleventhalbrad49439
 
How does a wave formation influence the resultant waveSolution.pdf
How does a wave formation influence the resultant waveSolution.pdfHow does a wave formation influence the resultant waveSolution.pdf
How does a wave formation influence the resultant waveSolution.pdfleventhalbrad49439
 
How are health services paid for Provide a definition for the term .pdf
How are health services paid for Provide a definition for the term .pdfHow are health services paid for Provide a definition for the term .pdf
How are health services paid for Provide a definition for the term .pdfleventhalbrad49439
 
Given the information regarding mitosis and meiosis, clearly and con.pdf
Given the information regarding mitosis and meiosis, clearly and con.pdfGiven the information regarding mitosis and meiosis, clearly and con.pdf
Given the information regarding mitosis and meiosis, clearly and con.pdfleventhalbrad49439
 
First, look to determine what is the earliest era that fossils have .pdf
First, look to determine what is the earliest era that fossils have .pdfFirst, look to determine what is the earliest era that fossils have .pdf
First, look to determine what is the earliest era that fossils have .pdfleventhalbrad49439
 
Figure out and write down a definition of a translation that does no.pdf
Figure out and write down a definition of a translation that does no.pdfFigure out and write down a definition of a translation that does no.pdf
Figure out and write down a definition of a translation that does no.pdfleventhalbrad49439
 
explain why right and why wrong Indentify configuration (below) whic.pdf
explain why right and why wrong Indentify configuration (below) whic.pdfexplain why right and why wrong Indentify configuration (below) whic.pdf
explain why right and why wrong Indentify configuration (below) whic.pdfleventhalbrad49439
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfleventhalbrad49439
 
Description of nonaxial movement Description of other types of move.pdf
Description of nonaxial movement Description of other types of move.pdfDescription of nonaxial movement Description of other types of move.pdf
Description of nonaxial movement Description of other types of move.pdfleventhalbrad49439
 
Centers for Medicare and Medicard Services is a very large purchaser .pdf
Centers for Medicare and Medicard Services is a very large purchaser .pdfCenters for Medicare and Medicard Services is a very large purchaser .pdf
Centers for Medicare and Medicard Services is a very large purchaser .pdfleventhalbrad49439
 
An alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfAn alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfleventhalbrad49439
 
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdf
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdfA small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdf
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdfleventhalbrad49439
 
A proof induction has two standard parts. The first establishing tha.pdf
A proof induction has two standard parts. The first  establishing tha.pdfA proof induction has two standard parts. The first  establishing tha.pdf
A proof induction has two standard parts. The first establishing tha.pdfleventhalbrad49439
 
A population has a proportion equal to 0.30. Calculate the following.pdf
A population has a proportion equal to 0.30. Calculate the following.pdfA population has a proportion equal to 0.30. Calculate the following.pdf
A population has a proportion equal to 0.30. Calculate the following.pdfleventhalbrad49439
 

More from leventhalbrad49439 (20)

The Antoine equation often is used to describe vapor pressures lnP .pdf
The Antoine equation often is used to describe vapor pressures lnP .pdfThe Antoine equation often is used to describe vapor pressures lnP .pdf
The Antoine equation often is used to describe vapor pressures lnP .pdf
 
The converson of the English to Christianity began a rich period of .pdf
The converson of the English to Christianity began a rich period of .pdfThe converson of the English to Christianity began a rich period of .pdf
The converson of the English to Christianity began a rich period of .pdf
 
Table 19. Highest Level of Type of organization germ layers .pdf
Table 19. Highest Level of Type of organization germ layers .pdfTable 19. Highest Level of Type of organization germ layers .pdf
Table 19. Highest Level of Type of organization germ layers .pdf
 
Question 12 (5 points)The reason that mitosis can result in the pr.pdf
Question 12 (5 points)The reason that mitosis can result in the pr.pdfQuestion 12 (5 points)The reason that mitosis can result in the pr.pdf
Question 12 (5 points)The reason that mitosis can result in the pr.pdf
 
peripheral circuit functions built-in to the HC12 microcontroller, t.pdf
peripheral circuit functions built-in to the HC12 microcontroller, t.pdfperipheral circuit functions built-in to the HC12 microcontroller, t.pdf
peripheral circuit functions built-in to the HC12 microcontroller, t.pdf
 
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdf
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdfMendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdf
Mendez Corporation has 10,000 shares of its $100 par value, 7 percen.pdf
 
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdf
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdfIf the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdf
If the dpy-11 and unc-31 genes are linked on the same chromosome, how.pdf
 
How does a wave formation influence the resultant waveSolution.pdf
How does a wave formation influence the resultant waveSolution.pdfHow does a wave formation influence the resultant waveSolution.pdf
How does a wave formation influence the resultant waveSolution.pdf
 
How are health services paid for Provide a definition for the term .pdf
How are health services paid for Provide a definition for the term .pdfHow are health services paid for Provide a definition for the term .pdf
How are health services paid for Provide a definition for the term .pdf
 
Given the information regarding mitosis and meiosis, clearly and con.pdf
Given the information regarding mitosis and meiosis, clearly and con.pdfGiven the information regarding mitosis and meiosis, clearly and con.pdf
Given the information regarding mitosis and meiosis, clearly and con.pdf
 
First, look to determine what is the earliest era that fossils have .pdf
First, look to determine what is the earliest era that fossils have .pdfFirst, look to determine what is the earliest era that fossils have .pdf
First, look to determine what is the earliest era that fossils have .pdf
 
Figure out and write down a definition of a translation that does no.pdf
Figure out and write down a definition of a translation that does no.pdfFigure out and write down a definition of a translation that does no.pdf
Figure out and write down a definition of a translation that does no.pdf
 
explain why right and why wrong Indentify configuration (below) whic.pdf
explain why right and why wrong Indentify configuration (below) whic.pdfexplain why right and why wrong Indentify configuration (below) whic.pdf
explain why right and why wrong Indentify configuration (below) whic.pdf
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
Description of nonaxial movement Description of other types of move.pdf
Description of nonaxial movement Description of other types of move.pdfDescription of nonaxial movement Description of other types of move.pdf
Description of nonaxial movement Description of other types of move.pdf
 
Centers for Medicare and Medicard Services is a very large purchaser .pdf
Centers for Medicare and Medicard Services is a very large purchaser .pdfCenters for Medicare and Medicard Services is a very large purchaser .pdf
Centers for Medicare and Medicard Services is a very large purchaser .pdf
 
An alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdfAn alarm system is to have 4 different devices, each with its sensor..pdf
An alarm system is to have 4 different devices, each with its sensor..pdf
 
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdf
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdfA small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdf
A small aquatic crustacean called Ceriodaphnia cornuta has two disti.pdf
 
A proof induction has two standard parts. The first establishing tha.pdf
A proof induction has two standard parts. The first  establishing tha.pdfA proof induction has two standard parts. The first  establishing tha.pdf
A proof induction has two standard parts. The first establishing tha.pdf
 
A population has a proportion equal to 0.30. Calculate the following.pdf
A population has a proportion equal to 0.30. Calculate the following.pdfA population has a proportion equal to 0.30. Calculate the following.pdf
A population has a proportion equal to 0.30. Calculate the following.pdf
 

Recently uploaded

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfElizabeth Walsh
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfKartik Tiwari
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 

Recently uploaded (20)

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Write an if statement to halt program if the program fails to opne a.pdf

  • 1. Write an if statement to halt program if the program fails to opne a file. Assuem the file to be opened has name "stats.dat". Solution C++ program #include #include using namespace std; int main () { ifstream infile; infile.open ("stats.dat"); if (infile.is_open()) { while (infile.good()) cout << "file opened successfully" << endl; infile.close(); } else { cout << "Error opening file"; } return 0; }