Question

Write a function that takes in the number of minutes past 12:00 PM and print the...

Write a function that takes in the number of minutes past 12:00 PM and print the corresponding time. C Language ONLY.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

void print_time(int seconds_after_12) {
    int hours, minutes, seconds;
    hours = seconds_after_12 / 3600;
    seconds_after_12 %= 3600;
    minutes = seconds_after_12 / 60;
    seconds = seconds_after_12 % 60;
    if (hours == 0)
        hours = 12;
    printf("%02d:%02d:%02d PM\n", hours, minutes, seconds);
}

int main() {
    print_time(10000);
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Write a function that takes in the number of minutes past 12:00 PM and print the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the python function time to midnight() that takes the name of a file containing multiple...

    Write the python function time to midnight() that takes the name of a file containing multiple lines of text giving time in HH:MM:SS HRS or HH:MM:SS AM or HH:MM:SS PM format one per line. The HRS notation indicates CSE 101 – Summer 2019 Lab Assignment #9 2 that the time has been given in 24-hour time format. Each line tells the current time of the day. The function reads the file line by line and calculates the number of seconds...

  • Write a function that takes two ints and returns the average (float) of those two ints....

    Write a function that takes two ints and returns the average (float) of those two ints. Include a function prototype. In main, call the function with two int inputs of your choice and print the returned value to the output window. The function should not print, just make the calculation an return the average. C language not C++

  • >Assessment Due in 14 hours, 5 minutes. Due Thu 04/04/2019 12:00 pm er is leaking out...

    >Assessment Due in 14 hours, 5 minutes. Due Thu 04/04/2019 12:00 pm er is leaking out of an inverted conical tank at a rate of 10500 cubic centimeters per min at the same time that water Wat is being pumped into the tank at a constant rate. The tank has height 15 meters and the diameter at the top is 6 meters. If r level is rising at a rate of 25 centimeters per minute when the height of the...

  • Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates...

    Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates and returns the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. In the main section of the program: Prompt the user to input a weight in pounds, Call the function you wrote to transform the weight into kilograms, Output the weight in kilograms; the number must be shown with 2 decimals after the decimal point. Your program must define and call...

  • Write a function that takes two arguments, both strings. Print "YES" if the second string argument...

    Write a function that takes two arguments, both strings. Print "YES" if the second string argument contains only characters found in the first string argument. Print "NO" if the second string argument contains characters not in the first. Here are some sample calls. In your program, call the function 3 times with the same arguments shown below. makeStr("hello", "") makeStr("hello", "olleloheloeloheloel") makeStr("hello", "olleloheloteloheloel") # YES # YES # NO

  • A) Write a function that receives an integer decimal number and converts it to its Hexadecimal...

    A) Write a function that receives an integer decimal number and converts it to its Hexadecimal equivalent B) Write a function that converts a binary number to its corresponding Decimal equivalent BOTH A AND B IN ARDUINO C LANGUAGE

  • Part 3 (Lab2a) In this exercise you will: a. Write a method called secondTime that takes...

    Part 3 (Lab2a) In this exercise you will: a. Write a method called secondTime that takes as argument an integer corresponding to a number of seconds, computes the exact time in hours, minutes and seconds, then prints the following message to the screen: <inputseconds> seconds corresponds to: <hour> hours, <minute> minutes and <second> seconds Write another method called in Seconds that takes as arguments three integers: hours, minutes and seconds, computes the exact time in seconds, then returns the total...

  • help Question 12 (20 points) Write a function named inverse that takes a single parameter, a...

    help Question 12 (20 points) Write a function named inverse that takes a single parameter, a dictionary. In this key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. dictionary each The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course For...

  • Write a stored function that takes a number as its input and returns that number as...

    Write a stored function that takes a number as its input and returns that number as currency, i.e. it should have a leading dollar sign, only have two decimal places, and have commas for the thousands. If the number is negative the result should be in parenthesis, accounting format, -123.45 returns ($123.45). If the input is a non-number, e.g. “Hello”, the function should return $0.00

  • Write a function with a variable number of arguments, that takes any number of integers as...

    Write a function with a variable number of arguments, that takes any number of integers as arguments and computes the average. Additionally write a main that calls this function at least twice on different numbers of arguments. Can this be done in command line and c++

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT