C++ Program to check whether a number is divisible by 5 and 11 or not by using user define functions. The number is divisible by 11 or 5 or not

Explanation:

  1. Pass-by-Value (isDivisibleByValue):
    • Function Definition: bool isDivisibleByValue(int num)
    • This function takes a single integer num as input by value (i.e., a copy of the number).
    • It checks if num is divisible by both 5 and 11 using the modulus operator.
    • Returns true if divisible by both, otherwise false.
  2. Pass-by-Reference (isDivisibleByReference):
    • Function Definition: void isDivisibleByReference(int num, bool &divisibleBy5, bool &divisibleBy11, bool &divisibleByBoth)
    • This function takes an integer num and three reference variables (divisibleBy5, divisibleBy11, divisibleByBoth).
    • It calculates and assigns the results directly to the reference variables:
      • divisibleBy5 indicates if num is divisible by 5.
      • divisibleBy11 indicates if num is divisible by 11.
      • divisibleByBoth indicates if num is divisible by both 5 and 11.
  3. Main Function (main):
    • The program prompts the user to input a number.
    • It then checks if the number is divisible by 5 and 11 using both methods and prints the results.

Example Outputs:

Example 1:

Input:

  • Number: 55

Output:

Example 2:

Input:

  • Number: 30

Output:

Example 3:

Input:

  • Number: 22

Output: