Skip to content

Add Subroutine for Even or Odd Number Check #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bavitha01
Copy link

Description:

This pull request introduces a new Perl script that checks whether a given number is even or odd using a subroutine. The script follows best practices, including strict and warnings for better debugging.

Changes Made:

  1. Added a subroutine check_even_odd($num) to determine if a number is even or odd.
  2. Used STDIN for user input and chomp to handle newline characters.
  3. Implemented a ternary conditional operator to return the result concisely.

How It Works:

  1. The script prompts the user to enter a number.
  2. The input is passed to the check_even_odd subroutine.
  3. The subroutine evaluates the number and returns either "Even" or "Odd".
  4. The result is printed to the console.

Testing:

Tested with multiple inputs to verify correctness.
Handles both even and odd numbers correctly.

Example output:
Enter a number: 8 8 is Even

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant