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
python help, fill in the "your response" parts Write function quoteByNum() that takes as input the name of a file (as a string) and an index i (as an integer). The file will contain quotes, one per line. The function should open the file, read the file, close the file, and return the i-th quote (i.e. the i-th line in the file), assuming that the quote numbering starts at 0. Test your solution on file Wilde_Quotes.txt.>>> quote("Wilde_Quotes.txt", 5)'At twilight, nature is not without loveliness, though perhaps its chief use is to illustrate quotations from the poets.\n'>>> quote("Wilde_Quotes.txt", 0)'A little sincerity is a dangerous thing, and a great deal of it is absolutely fatal.\n'>>> quote("Wilde_Quotes.txt", 23)'Patriotism is the virtue of the vicious. \n'>>>  def quoteByNum(file, int1):     your response  (docstring)                 infile = open(file)                          # your response                 content = infile your…
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…
Create the following programs in C++. Each program should be reading from a file (i.e., test1.txt, test2.txt, test3.txt) and then outputting the following to the screen. Note: No parameters in the main function Program 1: last line of the file Program 2: size of the longest line of the file
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