Computer Science, asked by abhikmal3696, 4 months ago

WAP buzz no. in java by using user defined​

Answers

Answered by shreyamishra8374
1

Answer:

Explanation:

A number is said to be Buzz Number if it ends with 7 OR is divisible by 7.

The task is to check whether the given number is buzz number or not.

Examples:

Input : 63

Output : Buzz Number

Explanation: 63 is divisible by 7, one

of the condition is satisfied.

Input : 72

Output : Not a Buzz Number

Explanation: 72 % 7 != 0, 72 is neither

divisible by 7 nor it ends with 7 so

it is not a Buzz Number.

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

// C++ program to check whether the

// given number is Buzz Number or not.

#include <cmath>

#include <iostream>

using namespace std;

// function to check BUzz number.

bool isBuzz(int num)

{

// checking if the number

// ends with 7 and is divisible by 7

return (num % 10 == 7 || num % 7 == 0);

}

// Driver method

int main(void)

{

int i = 67, j = 19;

if (isBuzz(i))

cout << "Buzz Number\n";

else

cout << "Not a Buzz Number\n";

if (isBuzz(j))

cout << "Buzz Number\n";

else

cout << "Not a Buzz Number\n";

}

Similar questions