C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.4, Problem 2E
Program Plan Intro
- 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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?
Chapter 8 Solutions
C++ for Engineers and Scientists
Ch. 8.1 - Prob. 1ECh. 8.1 - (Practice) a. Write a set of two statements...Ch. 8.1 - Prob. 3ECh. 8.1 - Prob. 4ECh. 8.1 - Prob. 5ECh. 8.1 - Prob. 8ECh. 8.1 - Prob. 9ECh. 8.1 - Prob. 10ECh. 8.2 - Prob. 1ECh. 8.2 - (Practice and modify) a. Enter and run Program...
Ch. 8.2 - (Practice and modify) a. Write a C++ program that...Ch. 8.2 - (Practice) Determine the OS command or procedure...Ch. 8.2 - Prob. 5ECh. 8.2 - (Data processing) a. Write a C++ program that...Ch. 8.2 - Prob. 7ECh. 8.2 - Prob. 8ECh. 8.2 - Prob. 9ECh. 8.3 - Prob. 1ECh. 8.3 - Prob. 2ECh. 8.3 - Prob. 3ECh. 8.3 - Prob. 4ECh. 8.3 - Prob. 5ECh. 8.3 - Prob. 6ECh. 8.4 - Prob. 1ECh. 8.4 - Prob. 2ECh. 8.4 - Prob. 3ECh. 8.4 - Prob. 4ECh. 8.5 - (Practice) Write a C++ program to create the...Ch. 8.5 - Prob. 2ECh. 8.5 - Prob. 3ECh. 8.5 - Prob. 4ECh. 8.5 - Prob. 5ECh. 8 - Prob. 1PPCh. 8 - (Data processing) a. Store the following data in a...Ch. 8 - (Data processing) Write a C++ program that allows...Ch. 8 - (Data processing) Write a C++ program that permits...Ch. 8 - (Data processing) Write a C++ program that reads...Ch. 8 - (Data processing) Write a C++ program that reads...Ch. 8 - Prob. 7PPCh. 8 - (Data processing) A bank’s customer records are to...Ch. 8 - (Inventory) Create an ASCII file with the...
Knowledge Booster
Similar questions
- PROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forward
- PROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardWhat does it mean to overload a function?arrow_forward
- (JS)Write a function named "tweets" that takes a string as a parameter. If a message can hold at most 280 characters, calculate the smallest number of messages needed to hold all of the text in the input. The function should return the number it calculated.arrow_forwardUSE C++programming languagearrow_forwardModule/Week 5 ASSIGNMENT (USER-DEFINED FUNCTIONS)Write a C++ program that reads data from an input file, takes the data and computes student grades for an assignment by converting the raw score to a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "Excellent" if the grade is greater than 90, "Well Done" if the grade is greater than 80, "Good" if the grade is greater than 70, "Need Improvement" if the grade is greater than or equal to 60, and "Fail" if the grade is less than 50. The main function is responsible for reading the input file and passing the appropriate arguments to your functions. Here is an example of…arrow_forward
- In C++ Language (please use hint) : Write a function which will swap its arguments if the first argument is greater than its second argument, but will not interchange them if the first argument is samller than or equal to the second argument. The function should return 1 if a swap was made, and 0 otherwise. (Hint: Make sure to use call by reference.) Write also a short test driver (i.e. a main() invoking your function).arrow_forwardOverview In this assignment you will create user-defined functions OUTSIDE the main program and call those functions from INSIDE the main program. Instructions This assignment will require you to create functions in the program which the main procedure calls. Write a C++ program that Reads data from an input file. The data file should include 10 students. Each student should have Takes the data and computes student grades for an assignment by converting the raw score to a percentage given each student's score and the total points. Round the final score up to the nearest whole value using the ceil function in the <cmath> header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "Excellent" if the grade is greater than 90, "Well Done" if the grade is greater than…arrow_forwardHow do you raise an exception in a function?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning