Algorithm and Flowchart to check whether a given number is buzz number or not

[495 views]



What are Buzz numbers?

A number is said to be a buzz number when if it ends with 7 or is divisible by 7. For example: 27, 49,157,63, etc.

Let us consider the number 1007:
1007 is a buzz number as it ends with 7.

Let us consider the number 56:
56 does not end with 7, but it is divisible by 7. Hence it is a buzz number.

In this article, we will learn about the algorithm and flowchart to check whether a given number is buzz number or not.

Algorithm to check whether a given number is buzz number or not :

Step 1: Start Step 2: Read the number from the user, say n Step 3: d = n % 10 Step 4: l = n % 7 Step 5: If d = 7 OR l = 0, then: 5.1: Display “Buzz number” Step 6. Else: 6.1: Display “Not a Buzz number” Step 7: Stop

Explanation:

In this problem, we need to check whether a given number is a buzz number or not. To check this, we need to check whether the number ends with 7 or is divisible by 7. If either of the two conditions is true, the number will be a buzz number.

The algorithm starts off by taking the number to checked as user input, the value is then stored in a variable, say ‘n’. We now find out whether the number ends with 7 or not. To check that, we extract the last digit of the number by doing: d = n % 10. The result is stored in the variable ‘d’. We now find out whether this is divisible by 7. To do this checking, we use the modulus operator. The checking is done by: l = n % 7. The result is stored in the variable ‘l’. Now, if d is equal to 7( which means the number ends with 7) or l is equal to 0( which means the number is divisible by 7), then the given number is a buzz number. If this checking returns true, we display “buzz number”, else, we display “Not a buzz number”.

Note: Here ‘%’ is the modulus operator which returns the remainder value after division.

Let us consider an example:
Let n = 1257
d = 1257 % 10
d = 7
Hence, 1257 is a buzz number.

Let us consider another example:
Let n = 217
l = 217 % 7
l = 0
Hence, 217 is a buzz number.

Flowchart to check whether a given number is buzz number or not :

Algorithm and Flowchart to check whether a given number is buzz number or not
Remove WaterMark from Above Flowchart

                 




Comments



Search

For any inquiry, Contact us at atechdailyweb@gmail.com




Facing Programming Errors. Get Answers within 24 hours:


Recommendation Based on your Interest




Quiz For You:
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Flowchart to check whether a given number is buzz number or not

    Pseudocode to check whether a given number is buzz number or not

    Check if number is Buzz Number algorithm