Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 3E
Write a function e that takes as its arguments two t structures and returns a t structure that represents the elapsed time (in hours, minutes, and seconds) between the two times. So the call
e
where t represents 3:45:15 and t represents 9:44:03, should return a t structure that represents 5 hours, 58 minutes, and 48 seconds. Be careful with times that cross midnight.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a function that receives 3 assignment grades, a1, a2, a3, and a final grade, f, for a student and returns the corresponding letter grade of the student. The weights for the assignments and the final are 0.2, 0.2, 0.2, and 0.4, respectively. You can use the following table for matching grades to letters: 95-100 -> A1 90-94 -> A2 85-89 -> A3 80-84 -> B1 75-79 -> B2 70-74 -> B3 65-69 -> C1 60-64 -> C2 55-59 -> C3 40-54 -> D 0-39 -> F For example, compute_letter(80, 60, 40, 70) returns "C2" because 80 * 0.2 + 50 * 0.2 + 40 * 0.2 + 70 * 0.4 = 62 and 62 corresponds to C2. Note that, you are expected to do rounding. For example, 39.4 is F, whereas 39.5 is D. You can use the builtin round() function for this. Please google this function and learn how to use it. """
Write a function that takes two integers and returns True if the integers have
a common divisor that is different than 1, otherwise returns False.
For example, notRelPrime(3,5) returns False, whereas notRelPrime (8,12) returns
True. Because, 3 and 5 have only one common divisor, which is 1, whereas 8 and
12 are both divisible by 1, 2 and 4.
def notRelPrime (a, b):
Write a function convertQuartersToDollars that has the noOfQuarters, noOfDollars, and remainingCents as formal parameters of data type int. The noOfQuarters is the number of quarters to be used to calculate noOfDollars, the number of dollars that the total number of quarters can be converted to, and remainingCents , the remaining cents. The noOfDollars and remainingCents are returned from the function,
Chapter 8 Solutions
Programming in C
Ch. 8 - Type in and run the seven programs presented in...Ch. 8 - In certain applications, particularly in the...Ch. 8 - Write a function e that takes as its arguments two...Ch. 8 - If you take the value of N as computed in exercise...Ch. 8 - Write a function called c that takes as its...Ch. 8 - Replace the d function from Program 8.4 with the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain what must be done when fully replicating a database but allowing only one computer to process updates.
Database Concepts (8th Edition)
To what class does the following constructor belong?
public Student (String name)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
When a parameter is changed, does this affect the argument that was passed into the parameter?
Starting Out with Python (3rd Edition)
While a program is running, a control is said to lose focus when the focus moves from that control to another c...
Introduction To Programming Using Visual Basic (11th Edition)
What is the output produced by the following lines of program code? intn=3;n++;System.out.printlnn==+n;n;System...
Absolute Java (6th Edition)
(Geometry: area of a triangle) Write a method that returns the area of a triangle using the following header: p...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
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
- 2. David is used to doing programming in Python and since the print() function in Python by default prints a newline after printing the string passed to the print() function. But in his current project, he is using PHP programming language and the echo function does not print a newline by default after the end of the string. So, he often misses giving a newline after printing a message. Help David by writing a function myecho() that takes a string as a parameter and also prints a newline after printing the string.arrow_forwardC++ Toll roads have different fees at different times of the day and on weekends. Write a function CalcToll() that has three arguments: the current hour of time (int), whether the time is morning (bool), and whether the day is a weekend (bool). The function returns the correct toll fee (double), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The function calls below, with the given arguments, will return the following toll fees: CalcToll(8, true, false) returns 2.95CalcToll(1, false, false) returns 1.90CalcToll(3, false, true) returns 2.15CalcToll(5, true, true) returns 1.05 Your program should include the function main( ), which asks for and validates the proper user inputs to be passed to the CalcToll( ) function. The function main() also displays the toll fees based…arrow_forwardWrite a function called subsequence() that finds the longest common subsequence of two DNA strands. The function should take two DNA strands (strings) as input and should return the longest common subsequence. Example:subsequence(“AATTCAT”, “CAT”) returns “CAT”subsequence(“CAAAT”, “CAT”) returns “CA”subsequence(“CCG”, “TTA”) returns “”subsequence(“AATGTTACCC”, “AATCTTACCT”) returns “TTACC”subsequence(“AATCTTAGCC”, “AATCAAAGCC”) returns “AATC”If there are multiple subsequences of the same length, then return the firstarrow_forward
- 1. Fibonacci series can be created starting from 0 to the desired number. A function can be written for this operation and it can take two parameters: start and end. The default fırst parameter 0 is acceptable. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765..arrow_forward12. John is used to doing programming in Python and since the print() function in Python by default prints a newline after printing the string passed to the print() function. But in his current project, he is using PHP programming language and the echo function does not print a newline by default after the end of the string. So, he often misses giving a newline after printing a message. Help David by writing a function myecho() that takes a string as a parameter and also prints a newline after printing the string.arrow_forwardThe function doit(a,b,c,d) is a function that multiplies the smallest of its integers arguments by 2. If more than one arguments are equal and are the smallest, they are multiplied by 2. For example given a=5,b=3,c=7,d=9, doit (a,b,c,d) changes b to 6. Write the code of the function doit and test it.arrow_forward
- Write a function future-date which takes four integer parameters: year, month, day and num-days. It will return the future date in num-days days. For example, (future-date 2015 2 3 29) returns (list 2015 3 4) meaning 29 days from Feb 3, 2015 will be Mar 4, 2015. Note that you do need to consider leap years (divisible by 4 but not by 100 unless it's divisible by 400). You may need an auxiliary function to decide the number of days each month has.arrow_forwardWrite a function days_in_month() that returns the number of days in a month in C . The function has the following prototype: int days_in_month(int month, int is_leap); Month should be an integer value between 1 and 12. The function should return (-1) if an invalid month is input. The variable ‘is_leap’ is 1 for leap years, 0 otherwise.arrow_forwardCreate a function that takes two integers, num and n, and returns an integer which is divisible by n and is the closest to num. If there are two numbers equidistant from num and divisible by n, select the larger one. Examples roundNumber (33, 25). - 25 roundNumber (46, 7)→ 49 roundNumber (133, 14) → 140arrow_forward
- Write a function that takes two integers and returns True if the integers have a common divisor that is different than 1, otherwise returns False. For example, notRelPrime(3,5) returns False, whereas notRelPrime(8,12) returnsTrue. Because, 3 and 5 have only one common divisor, which is 1, whereas 8 and 12 are both divisible by 1, 2 and 4.arrow_forwardWrite a function that asks the user for their birthday month and day and then the function should call a nested function to find out the person’s zodiac sign. Test your program with some user input. Aries: March 21 - April 19 Taurus: April 20 – May 20 Gemini: May 21- June 21 Cancer: June 22- July 22 Leo: July 23 – August 22 Virgo: August 23 – September 22 Libra: September 23 – October 23 Scorpio: October 24 – November 21 Sagittarius: November 22 – December 21 Capricorn: December 22 – January 19 Aquarius: January 20 – February 18 Pisces: February 19 – March 20arrow_forwardWrite a function sumOddInts(). sumOddInts should return the sum of all odd integers between the values provided to the two parameters, inclusive, e.g., sumOddInts(5,9) should return 21. start and finish do not have to be odd, e.g, sumOddInts (4,8) should return 12. start and finish do not have to be positive, e.g., sumoddlnts(-5,7) should return 7, However, finish may be assumed to be greater or equal to start. whereas Python has a modulo operator "%", MATLAB has a built-in mod() function that returns the remainder. For instance, >> mod (13,5) ans = 3 >> mod (13,2) ans = 1 Notes: End all assignment statements with a semi-colon to suppress output to screen. Include the key word end at the end of your function.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
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY