Question: The script below calls a function nexthour that receives one integer argument, which is an hour of the day, and returns the next hour on

The script below calls a function nexthour that receives one integer argument, which is an hour of the day, and returns the next hour on a 12-hour clock, regardless of whether the inputted current hour is on a 12-hour or 24-hour clock.

 Hour=input(Enter the current hour: ); Hour = floor(Hour); if Hour>=1 && Hour<=24 

fprintf(The next hour will be %d. , nexthour(Hour) ) else

 fprintf(Please enter a number from 1 to 24.) end 

Sample output from the program is provided below:

 Enter the current hour: 57 Please enter a number from 1 to 24. 
 Enter the current hour: 15 The next hour will be 4. 
 Enter the current hour: 12 The next hour will be 1. 

Write the function nexthour so that it produces the results shown above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!