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
Explain default dictionary in microsoft word​
seraphim [82]
The default custom dictionary is the dictionary to which Microsoft Word adds the word when you do this.
4 0
3 years ago
In the following code, what is the first line that introduces a memory leak into the program?
Fantom [35]

Answer:

The answer is "Line 13".

Explanation:

In the given code first, a header file is included for using basic function, In the next line the main method is defined in this method two-pointer variable is declared that is "numbers1 and numbers2", in which variable numbers1 holds a value that is "NULL".

  • In the next line, both variable uses malloc() function that is used to allocate memory in heap, and in this function, sizeof() function is used that print its size and also increase its value.
  • In the next step, a pointer variable numbers1 assigns a value and another variable numbers2 assigns numbers1 variable value and changes the numbers1 variable.
6 0
4 years ago
The two key elements of any computer system are the____and the _____.
Virty [35]
Easy.
Hardware and software!
Did you ever try to use a computer with only mouse and monitor?
8 0
3 years ago
Which two devices are paired to create a memory cell? what term is used to describe this common form of computer memory? (2 poin
elena-14-01-66 [18.8K]

A transistor and A capacitor

<h3>What are transistors and capacitors?</h3>
  • Transistors are semiconductor devices used to amplify or switch electronic signals.
  • Inductors are passive electrical devices in electrical circuits for their property of inductance.
  • While a capacitor opposes changes in voltage, an inductor opposes changes in current.

To learn more about it, refer

to https://brainly.in/question/413163

#SPJ4

6 0
2 years ago
_____ assures the interface will act as the users expect, while _____ assures it will look pleasing. Select one:
Agata [3.3K]

Answer:

C. consistency, aesthetics

Explanation:

Based on the descriptions given to us in the question we can deduce that the answer is C. consistency, aesthetics. This is because "consistency" is defined as something that always delivers the same results, which is what users need from the interface in order to understand it and continue using it. While "aesthetics" is defined as the visual representation of something (how something will look).

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
Other questions:
  • Brainliest to whoever can guess what year this corvette logo is from. Make your guesses
    11·1 answer
  • By default, the Windows desktop displays
    6·1 answer
  • What translates binary data into images on a monitor?
    8·1 answer
  • 1) Open the file DiceSimulation.java attached below. Create a new project on NetBeans called DiceSimulation. Copy the code from
    13·1 answer
  • To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method.
    8·1 answer
  • which feature of organisations to manage needs to know about to build and use information system successfully
    6·1 answer
  • U $ er Ideas for R 0 B 1 0 X?
    12·2 answers
  • Write a for loop to print the numbers from 20 to 30, inclusive (this means it should include both the 20 and 30). The output sho
    5·1 answer
  • Write a short essay about the best rotary-wing aircraft ever. It must be a specific aircraft and consist of three paragraphs. In
    9·1 answer
  • Which CPT icon should be considered when entering CPT codes into a spreadsheet for numerical sorting
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!