This program find out whether a entered number is divisible by 3 and 5 or not.
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 | #include "conio.h" #include "stdio.h" void main() { int num; printf("\nEnter a number "); scanf("%d",&num); if(num%3==0) { if(num%5==0) { printf("\nThe number %d is divisible by 3 and 5"); } else { printf("\nThe number %d is divisible by 3 but not by 5"); } } else { printf("\nThe number %d is niether divisible by 3 nor by 5"); } getch(); } |
Output:
Enter a number 21 Number is divisible by 3 but not by 5 |
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Resources #Terms of Use
Copyright©2012 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com
#include
void main()
{
int num;
printf(“\nEnter a number “);
scanf(“%d”,&num);
if(num%3==0)
{
if(num%5==0)
{
printf(“\nThe number %d is divisible by 3 and 5\n”,num);
}
else
{
printf(“\nThe number %d is divisible by 3 but not by 5\n”,num);
}
}
else
{
if(num%5==0)
“tdiv.c” 31 lines, 507 characters