Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12, Problem 1E
Explanation of Solution
Purpose of given code 12.1.:
- The code “
Program 12.1.” is to check given value is even or not. It has a function named “isEven()” which get an argument and checks the value of the argument is even using “if…else” condition. - If the given argument value is even, the macro value of “YES” stored into the variable “answer” otherwise it assigned macro value of “NO” to the variable “answer”.
- The main program calls the function with argument as “17” and “20”.
Expert Solution & Answer
Sample Output
no yes
Comparison:
The type in code prints the above output which is “equal” to the output presented in the text book. The function returns “no” for the input value “17” and returns “yes” for the input value “20”.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Explain in your own words:
a.) Why do we need file in programming?
b.) What is a potential error that can occur when a file is opened for reading?
In this post, we will be discussing file extensions as well as the programs that are responsible for their creation. The provision of examples is absolutely necessary.
Write a short notes on the following
appending to a file
deleting a file
Knowledge Booster
Similar questions
- (Practice) a. Write a set of two statements declaring the following objects as ifstream objects, and then opening them as text input files: inData.txt, prices.txt, coupons.dat, and exper.dat. b. Rewrite the two statements for Exercise 2a, using a single statement.arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. 1- Write code that does the following: opens an output file with the filename number_list.txt, uses a loop to write the numbers 1 through 100 to the file, then closes the file.arrow_forwardFirst make 3 text files that each one includes 10 names and also make one text file that includes integer numbers. Then: write a c++ that read the input file, which includes integer, then sort them(Ascending) and write in the same file.arrow_forward
- Draft a Python program that prompts the user for the name of two files. The script should copy the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns, so that the format of a line in the output file looks like this example:arrow_forwardShow how example code of how to ignore the repeated lines of code within a file using loops. No functions can be used to complete this.arrow_forward2. For reading and for processing data of employee records stored in a file named employee.txt,the contents of it need to be reversed from end to beginning. Write a C program to read a file in serial way, and reverse the contents of the employee record and then, again traverse and read the record in the newly reversed file.arrow_forward
- How do you parse through this input file? C++arrow_forwardWrite a function that accepts names of two files: source and target as arguments and copies alternate characters from the source file to the target file. The function should return -1 if the source file does not exist.arrow_forwardWrite a function to output patient information that are stored in a file. One of the parameters of the function must be no. of patients to output and another one the name of the file where the patients’ information is stored.arrow_forward
- C++ How do I read initial data in from a file, and then use class to store the data?arrow_forwardFind the error in each of the following program segments and explain how to correct it.a) The file referred to by fPtr ("payables.dat") has not been opened.printf(fPtr, "%d%s%d\n", account, company, amount);arrow_forwardd) Write a Python program to accept a filename from the user and print the extension of that. Input: Random.py Output: Pyarrow_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 Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr