Check buzz number in C
if else - Question 10
In this question, we will see how to check if a number is a buzz number or not in C programming using the if else statement. To know more about if else statement click on the if else statement lesson.
Q10) Write a program in C to input a number and check if it is a buzz number or not. A number is a buzz number if it is divisible by 7 or if its last digit is 7. Make use of logical operator || to solve this question.
Program
#include <stdio.h>
#include <conio.h>
int main()
{
int n;
printf("Enter a number ");
scanf("%d",&n);
if(n%7==0 || n%10==7)
{
printf("Buzz number");
}
else
{
printf("Not a buzz number");
}
return 0;
}
Output
Enter a number 21 Buzz number