Ask Question
17 November, 21:09

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.

+3
Answers (1)
  1. 17 November, 21:14
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers