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 3, Problem 3.31E
(Another Dangling-Else Problem) Modify the following code to produce the output shown. Use proper indentation techniques. You may not make any changes other than inserting braces. The compiler ignores the indentation in a
- Assuming x = 5 and y = 8, the foIIowing output is produced.
- Assuming x = 5 and y = 8, the following output is produced.
- Assuming x = 5 and y = 8, the following output is produced.
- Assuming x = 5 and y = 7, the following output is produced.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Don't use ai to answer I will report your answer.
.
Solve it Asap with explanation properly
(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 *******.
(Please do not give solution in image format thanku)
Using the evaluation semantics of SML, rewrite the following expression into its simplest form. If the expression is syntactically illegal or its evaluation results in an error, then simply write "error" as the result. (fn f => (fn y => f y))(fn x => 1 + 1)
Chapter 3 Solutions
C How to Program (8th Edition)
Ch. 3 - Indentify and correct the errors in each of the...Ch. 3 - Fill in the blanks in each of the following: The...Ch. 3 - Prob. 3.12ECh. 3 - Write a single pseudocode statement that indicates...Ch. 3 - Formulate a pseudocode algorithm for each of the...Ch. 3 - State which of the following are true and which...Ch. 3 - For Exercises 3.16-3.20, perform each of these...Ch. 3 - For Exercises 3.16 -3.20, perform each of these...Ch. 3 - (Sales-Commission Calculator) One large chemical...Ch. 3 - (Interest Calculator) The simple interest on a...
Ch. 3 - (Salary Calculator) Develop a program that will...Ch. 3 - (Predecrementing vs. Postdecrementing)Write a...Ch. 3 - (Printing Numbers from a Loop) Write a program...Ch. 3 - (Find the Largest Number) The process of finding...Ch. 3 - (Tabular Output) Write a program that uses looping...Ch. 3 - (Tabular Output) Write a program that utilizes...Ch. 3 - (Find the Two Largest Numbers) Using an approach...Ch. 3 - (Validating User Input) Modify the program in...Ch. 3 - Prob. 3.28ECh. 3 - Prob. 3.29ECh. 3 - (Dangling-Else Problem) Determine the output for...Ch. 3 - (Another Dangling-Else Problem) Modify the...Ch. 3 - Prob. 3.32ECh. 3 - (Hollow Square of Asterisks) Modify the program...Ch. 3 - (Palindrome Tester) A palindrome is a number or a...Ch. 3 - (Printing the Decimal Equivalent of a Binary...Ch. 3 - (How Fast Is Your Computer?) How can you determine...Ch. 3 - (Detecting Multiples of 10) Write a program that...Ch. 3 - (Counting 7s) Write a program that reads an...Ch. 3 - (Checkerboard Pattern of Asterisks) Write a...Ch. 3 - (Multiples of 2 with an Infinite Loop) Write a...Ch. 3 - (Diameter, Circumference and Area of a Cirle)...Ch. 3 - Whats wrong with the following statement? Rewrite...Ch. 3 - (Sides of a Triangle) Write a program that reads...Ch. 3 - (Sides of a Right Triangle) Write a program that...Ch. 3 - (Factorial) The factorial of a nonnegative integer...Ch. 3 - (World-Population-Growth Calculator) Use the web...Ch. 3 - (Target-Heart-Rate Calculator) While exercising,...Ch. 3 - (Enforcing Privacy with Cryptography) The...
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
- (Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour? cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…arrow_forward(Target-Heart-Rate Calculator) While exercising, you can use a heart-rate monitor to see thatyour heart rate stays within a safe range suggested by your trainers and doctors. According to the American Heart Association (AHA) (www.americanheart.org/presenter.jhtml?identifier=4736), theformula for calculating your maximum heart rate in beats per minute is 220 minus your age in years.Your target heart rate is a range that is 50–85% of your maximum heart rate. [Note: These formulas areestimates provided by the AHA. Maximum and target heart rates may vary based on the health, fitness andgender of the individual. Always consult a physician or qualified health care professional before beginning ormodifying an exercise program.] Create a class called HeartRates. The class attributes should include theperson’s first name, last name and date of birth (consisting of separate attributes for the month, dayand year of birth). Your class should have a constructor that receives this data as…arrow_forwardHi! I need help with this homework! (it is C prgramming ) Thank youarrow_forward
- (In java) Lab6C: Cha-Ching For this lab, use a do-while loop.A sentinel loop is a loop (a special while loop or a do-while loop) that continues to process data until itreaches a specific value(s) that signals that it should stop looping; this special value(s) is usuallyindicated as the condition of the while or do-while loop. A good example of a sentinel loop is the whileloop that you had to write to verify user input in Lab6B, the special values were anything in the range of1 to 1000. Another very common application for this is allowing a user to rerun a program.Please write a very simple program that mimics a bank account. The program should start the user outwith $1000. The program should print out a welcome menu once with the options present for the user.The program should allow the user to make a deposit, withdrawal, and see their current balance.Every time the user deposits or withdraws, the program should show the user their new balance; itshould also ask the user if they want…arrow_forward(Python GUI -Tkinker) You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaurant. You are not sure if any of them have dietary restrictions, but your restaurant choices are as follows: Joe’s Gourmet Burgers—Vegetarian: No, Vegan: No, Gluten-Free: No Main Street Pizza Company—Vegetarian: Yes, Vegan: No, Gluten-Free: Yes Corner Café—Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Mama’s Fine Italian—Vegetarian: Yes, Vegan: No, Gluten-Free: No The Chef’s Kitchen—Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Write a Python program GUI that asks whether any members of your party are vegetarian, vegan, or gluten-free, to which then displays only the restaurants to which you may take the group.arrow_forward[Updated[ Python Code Pt1: Algorithms and Data Structures Please use the sample input to see if the code works, as the output of the final code, must be the same as the correct output. Follow the details and notes provided and show the complete working sample code. Additionally, include comments to make the code easier to understand. I will show how the output was found (check K);Note: The final code should result in correct output (check I) if sample input A (check H) is used, or else I will give an automatic thumbs down A. TASKThe user inputs a path system and the work needed to traverse them. The goal is to Identify the relationships between paths, whether they have sequential, adjacent, or null relationships. For every sequential and adjacent relationship, give their work done based on the formula (check D). B. SAMPLE A path system illustration //See Image C. Relationship Examples with Sample A as basisSequential relationships: Path1 and Path2 as they are single paths that are…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( MindTap - Cenage )Example 5-6 implements the Number Guessing Game program. If the guessed number is not correct, the program outputs a message indicating whether the guess is low or high. Modify the program as follows: Suppose that the variables num and guess are as declared in Example 5-6 and diff is an int variable. Let diff = the absolute value of (num - guess). If diff is 0, then guess is correct and the program outputs a message indicating that the user guessed the correct number. Suppose diff is not 0. Then the program outputs the message as follows: If diff is greater than or equal to 50, the program outputs the message indicating that the guess is very high (if guess is greater than num) or very low (if guess is less than num). If diff is greater than or equal to 30 and less than 50, the program outputs the message indicating that the guess is high (if guess is greater than num) or low (if guess is less than num). If diff is greater than or equal to 15 and less than 30, the…arrow_forward(In Java) Mathletes Game! With the introduction of loops, we now know enough about programming to begincreating simple games. Our first game (sponsored by the KSU College of Science and Mathematics)will test your ability to solve multiplication problems.Your game will first ask the player if they want to play on easy or hard mode. Save their response inan appropriate variable (you will reference it later). Then, you will randomly generate two numbersand display them to the player in the form of a multiplication problem. The possible numbers willrange between -255 and 255.You will ask the player to solve the equation. You will keep creating multiplication questions until theplayer wins or loses.Based on whether the player chose “hard” or “easy” mode, the game will play a little differently.Refer to the following rules for the difference:Easy Mode Hard ModePlayer only has to answer 5 questions Player has to answer 10 questionsPlayer can try again if they get a question wrong(up to two…arrow_forward
- Please help answer these two questions in Python. (See attached image) Attach screenshots of your code for clarity.arrow_forward(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 = 8arrow_forward*USE Machinje Leaning* USe programmingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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