C Program to Find whether a number is Buzz Number or Not
The following example shows, how to find whether a number is a Buzz Number.
- Takes an integer input from the user.
- Checks if the number is divisible by 7.
- If not divisible, checks if the number ends with 7.
- Prints whether the number is a Buzz number or not.
Example : pgm.c
#include <stdio.h> int main() { int num; // Input a number printf("Enter a number: "); scanf("%d", &num); // Check for Buzz number using nested if if (num % 7 == 0) { printf("%d is a Buzz Number (divisible by 7).\n", num); } else { if (num % 10 == 7) { printf("%d is a Buzz Number (ends with 7).\n", num); } else { printf("%d is not a Buzz Number.\n", num); } } return 0; }
Output:
Enter a number: 27
27 is a Buzz Number (ends with 7).
Enter a number: 49
49 is a Buzz Number (divisible with 7).
Enter a number: 23
23 is not a Buzz Number.
27 is a Buzz Number (ends with 7).
Enter a number: 49
49 is a Buzz Number (divisible with 7).
Enter a number: 23
23 is not a Buzz Number.