Monday, 8 February 2016

Write a program that asks the user to enter an hour value and a minute value.The main() function should then pass these two values to a type void function that dis-plays the two values in the format shown in the following

Leave a Comment
Questions:

Write a program that asks the user to enter an hour value and a minute value.The main() function should then pass these two values to a type void function that dis-plays the two values in the format
shown in the following sample run:

Enter the number of hours: 9
Enter the number of minutes: 28
Time: 9:28

Explanation:

This problem is simple and just demonstration of basic console in,out and user defined function.  Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/


#include<iostream>
using namespace std;
//function prototype
void time(int,int);
void main() {
       int hour, minute;
       cout << "Enter Hour = ";
       cin >> hour;
       cout << "Enter Minute = ";
       cin >> minute;
       time(hour, minute);
}

//function defination
void time(int hour,int minute) {
       cout << "Time : " << hour << ":" << minute << endl;
}



Output:
Write a program that asks the user to enter an hour value and a minute value.The main() function should then pass these two values to a type void function that dis-plays the two values in the format  shown in the following


Related Articles:

C++ Books Solution

If You Enjoyed This, Take 5 Seconds To Share It