1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
3 years ago
15

Write a program that reads from user (i) an hour between 1 to 12 and (ii) number of hours ahead. The program should print the ti

me after those many hours
Computers and Technology
1 answer:
Lunna [17]3 years ago
8 0

Answer:

The cpp program for time calculation is given below.

#include <iostream>

using namespace std;

int main()

{

// variables declared but not initialized

   int hour;

   int hrs_ahead;

   int time;

   

   cout<<" Enter an hour between 1 to 12: ";

   cin>>hour;

   

   cout<<" Enter the required number of hours ahead: ";

   cin>>hrs_ahead;

   

   time = hour + hrs_ahead;

   

   //time is adjusted to display correct time in 12 hour format

   if(time > 12)

       time = time - 12;

   

 //final time is displayed to the console

   cout<<" The time after "<< hrs_ahead <<" hours is "<< time <<endl;

 //any integer can be returned but 0 is a standard practice

   return 0;

}

 

OUTPUT

Enter an hour between 1 to 12: 11

Enter the required number of hours ahead: 5

The time after 5 hours is 4

Explanation:

The program is described below.

1. The variables are declared to hold the three values, i.e., current hour, hours ahead and the final time. The variables are declared as integers since complete hour is to be stored.

2. User input is taken for both the current hour and hours ahead.

3. The final time is calculated by adding both the user inputs. The 12-hour time format is followed hence, the final time to be displayed is between 1 to 12.

4. The final time is displayed and a new line is inserted at the end.  

5. No validation is done for user input as per the requirement.

6. The output is displayed using keyword, cout.

7. The input is taken using keyword, cin.

8. All the code is written inside main() having return type integer.

9. The program ends with a return statement.

10. New line is inserted using the keyword, endl.

11.  The cpp language is not purely object oriented language hence use of classes is not mandatory.

12. The variables can also be declared at the beginning of the program and outside main() and any other methods created in the program.

You might be interested in
In what way do networks help to protect data?
kap26 [50]
Networks can provide a fire wall. What are the choices.
6 0
3 years ago
Read 2 more answers
What is the difference between a LAN and WAN? how do these two networks interact?​
stealth61 [152]
A LAN, abbreviated from Local Area Network, is a network that covers a small geographical area such as homes, offices, and groups of buildings. Whereas a WAN, abbreviated from Wide Area Network, is a network that covers larger geographical areas that can span the globe.

A Wide Area Network (WAN) operates over a much larger area, as they interconnect LANs to allow them to exchange data.
3 0
3 years ago
Which of the following Information Technology career fields generally requires the lowest level of education for an entry-level
Art [367]
I believe the correct answer from the choices listed above is option A. The <span> Information Technology career fields that generally requires the lowest level of education for an entry-level position would be </span><span>Information Services and Support. Hope this answers the question.</span>
5 0
3 years ago
Read 2 more answers
How should tools be stored <br>​
sweet-ann [11.9K]
You should store tools in a storage or tool box
4 0
3 years ago
2- There are many different design parameters that are important to a cache’s overall performance. Below are listed parameters f
katen-ka-za [31]

Answer:

1. 2588672 bits

2. 4308992 bits

3. The larger the data size of the cache, the larger the area of ​​memory you will need to "search" making the access time and performance slower than the a cache with a smaller data size.

Explanation:

1. Number of bits in the first cache

Using the formula: (2^index bits) * (valid bits + tag bits + (data bits * 2^offset bits))

total bits = 2^15 (1+14+(32*2^1)) = 2588672 bits

2. Number of bits in the Cache with 16 word blocks

Using the formula: (2^index bits) * (valid bits + tag bits + (data bits * 2^offset bits))

total bits = 2^13(1 +13+(32*2^4)) = 4308992 bits

3. Caches are used to help achieve good performance with slow main memories. However, due to architectural limitations of cache, larger data size of cache are not as effective than the smaller data size. A larger cache will have a lower miss rate and a higher delay. The larger the data size of the cache, the larger the area of ​​memory you will need to "search" making the access time and performance slower than the a cache with a smaller data size.

5 0
3 years ago
Other questions:
  • While Angela is making modifications to Katie’s Word document, she would like to inform Katie of the reasoning for the change. W
    10·1 answer
  • Select the correct statement about data preparation.
    10·1 answer
  • The mathematical order of operations is used in Excel when formulas are evaluated. This order of operations states the order to
    14·2 answers
  • solve this simple question 1) Let S = {a, bb, bab, abaab} be a set of strings. Are abbabaabab and baabbbabbaabb in S*? Does any
    8·1 answer
  • What permission do users have by default regarding printer access and the ability to manage documents?
    14·1 answer
  • The best way to safeguard your document is to save it
    11·1 answer
  • List two ways to insert a chart in powerpoint
    14·1 answer
  • I want to make apps but I don't know how and which things I have to learn first ,so if you know mention from starting to ending​
    11·1 answer
  • Brainliest For Tascake Because People Texted Before Tascake Could<br><br> Hurry Tascake
    13·2 answers
  • the php function that is executed is a connection to a database cannot be made is the____ function. die | isset| end | connect.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!