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:
Output:
Related Articles:
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:
Related Articles:
1 Questions:
the given solution is wrong
void main must be replaced by int main
and return 0 must be added
Post a Comment