forked from dimpeshmalviya/C-Language-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuzzNumberChecker.c
More file actions
42 lines (36 loc) · 925 Bytes
/
BuzzNumberChecker.c
File metadata and controls
42 lines (36 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdbool.h> // Include for using the bool type (true/false)
/**
* @brief Checks if a given number is a Buzz number.
* A Buzz number is a number that is either divisible by 7 or ends in the digit 7.
*
* @param num The integer to check.
* @return true if the number is a Buzz number, false otherwise.
*/
bool isBuzzNumber(int num)
{
// A number is a Buzz number if either of these conditions is true.
if (num % 7 == 0 || num % 10 == 7)
{
return true;
}
return false;
}
int main()
{
int number;
// Prompt the user to enter a number
printf("Enter a number to check if it's a Buzz number: ");
// Read the integer from the user
scanf("%d", &number);
// Call the isBuzzNumber function and check the result
if (isBuzzNumber(number))
{
printf("%d is a Buzz number.\n", number);
}
else
{
printf("%d is not a Buzz number.\n", number);
}
return 0;
}