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 in C progarmming language that gets a string str, changes all lower case letters to * (asterisk), and all upper case letters to $ (dollar sign). All other characters remain unchanged. The function returns the total number of letters modified.
int hide_letters(char* str);
For example:
- If str is "12ab0", then the function changes it to "12**0", and returns 2.
- If str is "aBCDe*", then the function changes it to "*$$$**", and returns 5.
- If str is "0123&***", then the function keeps the string as is, and returns 0.
- An empty string is also a string.
Write a function in C language that takes the time as three integer arguments (for hours, minutes, and seconds) and returns the number of seconds since the last time the clock “struck 12.” Use this function to calculate the amount of time in seconds between two times, both of which are within one 12-hour cycle of the clock.
In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and otherwise it returns a^2 + b^3.
int square_cube (int a, int b);
For example:
square_cube (1,2) should return 1 + 8 = 9.
square_cube (10, 3) should return 1000 + 9 = 1009.
square_cube (2, -1) should return 8 + 1 = 9.
square_cube (-2, -1) should return 4 - 1 = 3.
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
- Write a program in c++ that calculates the area and perimeter of an upright rectangle.Create a struct Point that has two double values, x and y. Write a function that asks the user for a Point. Call that function twice, once to get the bottom left corner of a rectangle, and once to get the top right corner. Write another function that takes two Points and returns area and perimeter. Print out the area and perimeter. Given two points (x1,y1) and (x2,y2), the formulas to compute perimeter and area are as follows P erimeter = 2 ∗ (abs(x1 − x2) + abs(y1 − y2))Area = abs(x1 − x2) ∗ abs(y1 − y2)arrow_forwardWrite a c++ program: Write a function named convertToLowestTerms that inputs two integer parameters by reference named numerator and denominator. The function should treat these variables as a fraction and reduce them to lowest terms. For example, if numerator is 20 and denominator is 60, then the function should change the variables to 1 and 3, respectively. This will require finding the greatest common divisor for the numerator and denominator then dividing both variables by that number. If the denominator is zero, the function should return false, otherwise the function should return true. Write a driver program that uses convertToLowestTerms to reduce and output several fractions.arrow_forwardWrite a function rps in Python that returns the result of a game of "Rock,Paper, Scissors". The function accepts two arguments, each one of 'R','P','S' , that represents the symbol played by each of the two players. The function returns: -1 if the first player wins0 if a tie1 if the second player winsScissors beats Paper beats Rock beats Scissors Sample usage: >>> rps('R','P') # player 2 wins, return 11arrow_forward
- write a C program named turn_to_letter that decides on the letter grade of the student according to the table below from the visa and final grades sent into it and returns it, write it together with a main function which the turn_to_letter function is called and prints the letter equivalent on the screen. -Success score = 40% of midterm + 60% of final, -F for the success score below 50, D for between 50 and 59, C for between 60 and 69, B for between 70 and 79, A for 80 and above.arrow_forwardWrite a C++ Program that calculates the area and perimeter of an upright rectangle.Create a struct Point that has two double values, x and y. Write a function that asks the user for a Point.Call that function twice, once to get the bottom left corner of a rectangle, and once to get the top right corner.Write another function that takes two Points and returns area and perimeter. Print out the area and perimeter.Given two points (x1, y1) and (x2, y2), the formulas to compute perimeter and area are as followsPerimeter = 2 ∗ (abs(x1 − x2) + abs(y1 − y2))Area = abs(x1 − x2) ∗ abs(y1 − y2)arrow_forwardWrite a C++ function called first_alpha that takes three string parameters and returns the string that comes first alphabetically from among those three. You may assume that the strings are all lowercase.arrow_forward
- Write a function str_replace that takes three strings, str1, str2 and str3; and replaces the first occurence (if any) of str2 in str1 with str3, and returns the newly formed string. For example, str_replace("Nuclear Energy Engineering", "Nuclear Energy", "Mechanical") returns "Mechanical Engineering"arrow_forwardWrite 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. """arrow_forwardWrite 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,arrow_forward
- • Write a function for a double function that will accept either two or three parameters of type double. • If it only receives two parameters, then it will return the average of the two numbers. • If it receives three parameters, then it will return the average of the largest number and the smallest number. • Write a complete C++ program to show the use of this function.arrow_forwardWrite a C program that reserves flight tickets for 150 customers to Germany. Write afunction RegCust that for each customer gets name, surname, Passport ID, and age. If the age ofthe customer is less than 18 years old, the customer is not allowed to buy a ticket and the programmust show a warning message to the user. Write another function ResTCKT that reserves thetickets by saving the Passport ID and seat number for the customers. Seat numbers must beassigned randomly between 1 and 150 with no repeating random number. Write a third functionPrintTCKT that shows the complete name of customers and their seat number as tabular formatshown below. You need to use array of structures and pointers for implementation of thisprogram.Struct Customer{char *name;char *surname;int passID;int age;} Custs[150]; Struct Ticket{int passID;int seatNum;} TCKT[150];arrow_forwardWrite a function curconv() that takes as input:1. a currency represented using a string (e.g., 'JPY' for the Japanese Yen or'EUR' for the Euro)2. an amountand then converts and returns the amount in US dollars.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