Program to take the hours and minutes as input by the user and the show that whether it is AM or PM using user define functions

Pass-by-Value

In this approach, the function receives a copy of the hours and minutes, so any changes made within the function do not affect the original variables.

Pass-by-Reference

In this approach, the function receives references to hours and minutes, allowing any changes made within the function to affect the original variables.

Explanation

  • Pass-by-Value: The determineAMPM function receives copies of hours and minutes. It performs the AM/PM conversion logic based on these copies. The original variables in main are not modified.
  • Pass-by-Reference: The determineAMPM function receives references to hours and minutes. This allows the function to work directly with the variables from main. However, in this case, there are no modifications to hours and minutes, so the effect of pass-by-reference is similar to pass-by-value.

Sample Output

Assuming you enter 14 for hours and 30 for minutes:

For Pass-by-Value:

For Pass-by-Reference:

 

 

All Copyrights Reserved 2025 Reserved by T4Tutorials