Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions