C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 2.24E
(Odd or Even) Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(IN C LANGUAGE) Cumulative Addition: Computer selects a number between 7 and 23 at random. User will only add 2, 3 or 5 numbers to reach that number.For example: To reach 14:
User will enter 5 5 2 2 (4 input).Also he can enter 2 2 2 2 2 2 2 (7 input) or 3 3 3 3 2 (5 input).
https://www.bartleby.com/questions-and-answers/in-c-language-cumulative-addition-computer-selects-a-number-between-7-and-23-at-random.-user-will-on/0509c740-d993-44ed-a468-7e02da552600
[Calculate grades’ average for a student] write a program that calculates the student grades’ average for a semester for the number of courses taken in that semester. Your program should do the following:
1.Read from user the number of courses (n)
2. Then, read the courses’ grades for n times (Hint: use a loop)
3.If a grade is grater than 100 or less than 0, ask the user to enter the grade again.
4.Calculate the average of grades using the following formula:
average = (sum of grades) / n
5.Print out the average grade on the screen.
Note: Always use appropriate data types.
(Financial: credit card number validation) Credit card numbers follow certain pat-
terns. A credit card number must have between 13 and 16 digits. It must start with:
4 for Visa cards
5 for Master cards
37 for American Express cards
6 for Discover cards
In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card
numbers. The algorithm is useful to determine whether a card number is entered
correctly or whether a credit card is scanned correctly by a scanner. Credit card
numbers are generated following this validity check, commonly known as the
Luhn check or the Mod 10 check, which can be described as follows (for illustra-
tion, consider the card number 4388576018402626):
1. Double every second digit from right to left. If doubling of a digit results in a
two-digit number, add up the two digits to get a single-digit number.
4388576018402626
→ 2 * 2 = 4
→ 2 * 2 = 4
→ 4 * 2 = 8
→ 1 * 2 = 2
6 * 2 = 12 (1+ 2 = 3)
→ 5 * 2 = 10 (1+ 0 = 1)
→ 8 * 2 = 16 (1 + 6 = 7)
→ 4 * 2 = 8
Chapter 2 Solutions
C How to Program (8th Edition)
Ch. 2 - Identify and correct the errors in each of the...Ch. 2 - Fill in the blanks in each of the following: _____...Ch. 2 - Write a single C statement or line that...Ch. 2 - State which of the following are true and which...Ch. 2 - Prob. 2.11ECh. 2 - What, if anything, prints when each of the...Ch. 2 - Which, if any, of the following C statements...Ch. 2 - Given the equation y=ax3+7, which of the...Ch. 2 - State the order of evaluation of the operators in...Ch. 2 - (Arithmetic) Write a program that asks the user to...
Ch. 2 - (Printing Values with print!) Write a program that...Ch. 2 - (Comparing Integers) Write a program that asks the...Ch. 2 - (Arithmetic, Largest Value and Smallest Value)...Ch. 2 - (Diameter, Circumference and Area of a Circle)...Ch. 2 - Prob. 2.21ECh. 2 - What does the following code print? printf( *\n) ;Ch. 2 - (Largest and Smallest Integers) Write a program...Ch. 2 - (Odd or Even) Write a program that reads an...Ch. 2 - Print your initials in block letters down the...Ch. 2 - (Multiples) Write a program that reads in two...Ch. 2 - (Checkerboard Pattern of Asterisks) Display the...Ch. 2 - Prob. 2.28ECh. 2 - (Integer Value of a Character) Heres a peek ahead....Ch. 2 - (Separating Digits in an Integer) Write a program...Ch. 2 - (Table of Squares and Cubes) Using only the...Ch. 2 - (Body Mass Index Calculator) We introduced the...Ch. 2 - Prob. 2.33MD
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
An online or hard-copy repository for all project correspondence, inputs, outputs, deliverables, procedures, an...
Essentials of Systems Analysis and Design (6th Edition)
How does a computers main memory differ from its auxiliary memory?
Java: An Introduction to Problem Solving and Programming (7th Edition)
A byte is made up of eight a. CPUs b. addresses c. variables d. bits
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Suppose that we create an array A of GameEntry objects, which has an integer scores field, and we clone A and s...
Data Structures and Algorithms in Java
The job of the _____ is to fetch instructions, carry out the operations commanded by the instructions, and prod...
Starting Out With Visual Basic (7th Edition)
What output will the following lines of code display on the screen? cout "The works of Wolfgang\ninclude the f...
Starting Out with C++: Early Objects
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please answer item number 4. (pyhthon programming)arrow_forward) that generates a random even positive integer less than 10 Write a program (Li and displays, using asteriskS, a filled diamond. For example, if the generated length is 4, the program should display a filled diamond like the one below.arrow_forwardFactorial) The factorial of a nonnegative integer n is written n! (pronounced “n factorial”) and is defined as follows:For example, 5!= 5.4.3.2.1 , which is 120. Use while statements in each of the following:A. Write a program that reads a nonnegative integer and computes and prints its factorial.B. Write a program that estimates the value of the mathematical constant e by using the formula:Prompt the user for the desired accuracy of e (i.e., the number of terms in the summation).C. Write a program that computes the value of by using the formula Prompt the user for the desired accuracy of e (i.e., thenumber of terms in the summation).arrow_forward
- (DEBUG AND MAKE A FLOWCHART OF THIS PROGRAM) // This pseudocode is intended to display// employee net pay values. All employees have a standard// $45 deduction from their checks.// If an employee does not earn enough to cover the deduction,// an error message is displayed.// This example is modularized.start Declarations string name string EOFNAME = ZZZZ while name not equal to EOFNAME housekeeping() endwhile while name not equal to EOFNAME mainLoop() endwhile while name not equal to EOFNAME finish() endwhilestop housekeeping() output "Enter first name or ", EOFNAME, " to quit "return mainLoop() Declarations num hours num rate num DEDUCTION = 45 num net output "Enter hours worked for ", name input hours output "Enter hourly rate for ", name input rate gross = hours * rate net = gross - DEDUCTION if net > 0 then output "Net pay for ", name, " is ", net else output "Deductions not covered. Net is…arrow_forward(Algebra: solve 2 x 2 linear equations) You can use Cramer's rule to solve the following 2 X 2 system of linear equation: ed – bf ax + by = e cx + dy = f af - eс y ad – bc %3D ad – bc Write a program that prompts the user to enter a, b, c, d, e, and f, and displays the result. If ad – bc is 0, report that "The equation has no solution."arrow_forwardQ5. (Find the second lowest interger number) Write a program that prompts the user to enter a set of integer numbers, and finally displays the second lowest integer number in the set. To exit from the program enter -1. Here is a sample run Enter a set of integer numbers: 3 57 928-1 The second lowest number is 3.arrow_forward
- Q3. (Dice Rolling) Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. The sum of the two values should then be calculated. [Note: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums.] Figure 7.26 shows the 36 possible combinations of the two dice. Your program should roll the two dice 10,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals are reasonable (i.e., there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7). 1 2 3 4 5 1 2 4 6 7 3 4 6 7 3 4 5 7 8 9 4 7 8 9 10 7 8 10 11 7 10 11 12 Row\Col 3.arrow_forward(Algebra: solve 2 x 2 linear equations) You can use Cramer's rule to solve the following 2 x 2 system of linear equation: ax + by = e ed – bf af- ec ad - bc cx + dy = f ad – bc y = Write a program that prompts the user to enter a and f and display the result. If ad - bc is 0 b, c, d , e, , report that The equation has no solution.arrow_forward(Bar-Chart Printing Program) One interesting application of computers is drawing graphsand bar charts. Write a program that reads five numbers (each between 1 and 30). For each numberread, your program should print a line containing that number of adjacent asterisks. For example,if your program reads the number seven, it should print *******.arrow_forward
- 6. (Geometry: area of a pentagon) The area of a pentagon can be computed using the following formula (s is the length of a side): Area 5x s² 4 X tan TT 5 Write a program that prompts the user to enter the side of a pentagon and displays the area. Here is a sample run: Enter the side: 5.5 Enter The area of the pentagon is 53.04444136781625arrow_forwardAlert dont submit AI generated answer.arrow_forwardQ1:Write C code for a program that reads two positive integer number, checks whether these number are co-prime or not, and prints the result.Note: two numbers are co-prime numbers if they do not have a common factor other than 1. For example, 10 and 11 are co-prime.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License