Friday, May 11, 2012
Program to check that entered no is divisible by 5 or not.
//program to check that entered no is divisible by 5 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s,i;
printf("Enter the no ");
scanf("%d",&n);
s=0;
for(i=0;i<1;i++)
{ r=n%10;
n=n/10;
}
if(r==0||r==5)
printf("Entered no is divisible by 5");
else
printf("Entered no is Not divisible by 5");
getch();
}
Program to count number of digits in a number.
// program to count number of digits in a number.
#include<stdio.h>
#include<conio.h>
main()
{
int num,count=0;
printf("Enter a number: ");
scanf("%d",&num);
while(num)
{
num=num/10;
count++;
}
printf("Total digits is: %d",count);
getch();
}
Program to check that entered no is divisible by 9 or not.
//program to check that entered no is divisible by 9 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
printf("Enter the no ");
scanf("%d",&n);
s=0;
while(r!=0)
{ r=n%10;
n=n/10;
s=s+r;
}
if(s%9==0)
printf("Entered no is divisible by 9");
else
printf("Entered no is Not divisible by 9");
getch();
}
Program to check that entered no is divisible by 10 or not.
//program to check that entered no is divisible by 10 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s,i;
printf("Enter the no ");
scanf("%d",&n);
s=0;
for(i=0;i<1;i++)
{ r=n%10;
n=n/10;
}
if(r==0)
printf("Entered no is divisible by 10");
else
printf("Entered no is Not divisible by 10");
getch();
}
Thursday, May 3, 2012
Program to check that entered no is divisible by 3 or not.
//program to check that entered no is divisible by 3 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
printf("Enter the no ");
scanf("%d",&n);
s=0;
while(r!=0)
{ r=n%10;
n=n/10;
s=s+r;
}
if(s%3==0)
printf("Entered no is divisible by 3");
else
printf("Not divisible by 3");
getch();
}
Subscribe to:
Comments (Atom)