Ask Question
8 April, 16:58

Write a Function procedure that determines whether a given Integer is divisible by 5 or not. The function should accept one argument having a data type of Integer and return True if that Integer is divisible by 5, False otherwise.

+4
Answers (1)
  1. 8 April, 20:50
    0
    bool isdivisor (int x) / / function definition

    {

    if (x%5==0) / / check Integer is divisible by 5

    {

    return true;

    }

    else

    {

    return false;

    }

    }

    Explanation:

    #include / / header file

    using namespace std; / / using namespace std;

    bool isdivisor (int num); / / prototype

    int main () / / main function

    {

    bool t; / / bool variable

    int num; / / variable declarartion

    cout<<" enter the num:";

    cin>>num; / / input number

    t=isdivisor (num); / / calling

    if (t)

    cout<<" number is divisible by 5 ";

    else

    cout<<" number is not divisible by 5";

    return 0;

    }

    bool isdivisor (int x) / / function definition

    {

    if (x%5==0)

    {

    return true;

    }

    else

    {

    return false;

    }

    }

    Output:

    enter the num:50

    number is divisible by 5

    Explanation:

    In this program we have a declared a Boolean function i. e isdivisor that accept one argument of type int.

    check if (x%5==0) it return true otherwise false.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a Function procedure that determines whether a given Integer is divisible by 5 or not. The function should accept one argument having ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers