Your program must keep on prompting the user if an incorrect time was given; see below for examples. The program then converts the time into the usual US format with hours from 1 to 12, the minutes and an AM or PM marker. This conversion works like follows: • 0 hours become 12 o’oclock AM, • 1 through 11 hours become 1 through 11 hours AM, • 12 hours become 12 o’clock PM, • 13 through 23 hours become 1 through 11 hours PM, with a subtraction of 12. The program then displays the time in the usual US format. Please use care when displaying the minutes, as an extra zero needs to be displayed for minutes 0 to 9. See the examples below for details. Examples of input and output: Please enter the hours on a 24 hour clock (0-23): 15 Please enter the minutes (0-59): 7 You entered 3:07PM Please enter the hours on a 24 hour clock (0-23): 27 Please enter the minutes (0-59): 17 Sorry, your input is incorrect. Write a program clock.c that asks the user to input a moment in time as an hour and a minute. The hours are given in a 24 hour (European/Military) format, with hours from 0 to 23. The minutes are given as usual, between 0 and 59.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps