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…
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