C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Question
Book Icon
Chapter 8.4, Problem 2E
Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare required variables.
  • Declare object of ifstream.
  • Declare function header, fcheck()with object of ifstream as a formal parameter.
  • Declare afunctionfcheck()to check that the file exits or not.
  • Useif statement to check that the file exist.
  • Open the file, by using open() method.
  • int main() function is used to perform all the tasks.
  • Display the calculated results to the user.

Program Description: The main purpose of the program is to declare a function, fcheck()to check that the given file exits or not and if the file exist, then function should return 1 otherwise it will return 0.

Blurred answer
Students have asked these similar questions
Write in C++ Language.   (Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an object of both of these classes and print the same.
Discussion: Files with .h extension are called header files in C. These header files generally contain function declarations which we can be used in main C program, like for e.g. to include stdio.h in C program to use function printf()   Exercise 2. Creating myhead.h : Write the below code and then save the file as myhead.h or you can give any name but the extension should be .h indicating it’s a header file.   // It is not recommended to put function definitions  // in a header file. Ideally there should be only // function declarations. Purpose of this code is // to only demonstrate working of header files. void add(int a, int b) {     printf("Added value=%d\n", a + b); } void multiply(int a, int b) {     printf("Multiplied value=%d\n", a * b); }   Including the .h file in other program : Now as we need to include stdio.h as #include in order to use printf() function. We will also need to include the above header file myhead.h as #include”myhead.h”. The ” ” here are used to instruct…
Under what circumstances can you successfully return a pointer from a function?
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning