‘C’ program to check if number is divisible by 3 or 5.
C File =>
/* Write a ‘C’ program to accept an integer and check if it is divisible by
3 and 5. */
#include<stdio.h>
int main()
{
int num;
printf("\n Enter number : ");
scanf("%d",&num);
if(num%3==0 && num%5==0)
printf("\n %d is divisible by both 3 and 5",num);
else if(num%3==0)
printf("\n %d is divisible by only 3",num);
else if(num%5==0)
printf("\n %d is divisible by only 5",num);
else
printf("\n %d is not divisible by 3 and 5",num);
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.