Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
Expert Solution & Answer
Book Icon
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
Check Mark
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
Use Scanner and File to read input from a file. Use PrintStream and File to write output to a file. Write and call methods that accept parameters and return values to manage information flow and add structure to programs. Follow prescribed conventions for spacing, indentation, naming, and comments. Notice that if an input file is not found, either for creating a mad-lib or viewing an existing one, the user is re-prompted. No re-prompting occurs for the output file. If the output file does not already exist, it is created. If it does already exist, its contents are overwritten. (These are the default behaviors in Java.) You may assume that the output file is not the same file as the input file. When you are viewing an existing mad lib story, you are simply reading and echoing its contents to the console. You do not need to do any kind of testing to make sure that the story came from a mad lib input file; just output the file's contents. Menu options can be chosen in any order and are…
In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard input device (keyboard) and outputs the results on the standard output device (screen). The program can process only 20 numbers. Rewrite the program to incorporate the following requirements:a. Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file. b. Save the output of the program in a file.c. Modify the function getNumber so that it reads a number from the input file (opened in the function main), outputs the number to the output file (opened in the function main), and sends the number read to the function main. Print only 10 numbers per line.d. Have the program find the sum and average of the numbers.e. Modify the function printResult so that it outputs the final results to the output file (opened in the function main). Other than outputting…
(5) Write a function called copy_even_lines() that takes two strings (filenames) as input parameters and copies every other line from the first file into the second. That is, counting from 0, it copies the 0th line, the 2nd line, the 4th line, etc. from the first file to the second file. You may assume that both files exist. (6) Write a python program that asks the user for two filenames and calls your function copy_even_lines() from (5) using those two filenames. If one or more files do not exist, your program must handle the exception by repeating the prompts until valid filenames are entered.
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