212k views
3 votes
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.

User Alex Maker
by
7.5k points

1 Answer

3 votes

Answer:

bool isdivisor(int x) // function definition

{

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

{

return true;

}

else

{

return false;

}

}

Step-by-step explanation:

#include <iostream>// 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

Step-by-step 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 .

No related questions found