Practice
Rounding Comparison Function
2023/Feb/Mar·Variant 2
MEDIUMProcedures & Functions
Write a program that defines and tests a function called Same.
The function Same(A, B) should take an integer A and a real number B as parameters, and return TRUE if the value of A is the same as the value of B when B is rounded to the nearest whole number. Otherwise, it returns FALSE.
After defining the function, your program should input an integer X and a real number Y, call the function, and output "Match" if it returns TRUE, or "No Match" if it returns FALSE.
Input: An integer X followed by a real number Y.
Output: "Match" or "No Match".
Example:
Input: 5
4.8
Output: Match
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Rounds up to match
Inputs: 5, 4.8
Expected: Match
Test 2: Rounds down to match
Inputs: 5, 5.2
Expected: Match
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade