/***********************************************************************/
/* PROGRAM TO DETECT WHETHER ENTERED NUMBER IS DIVISIBLE BY 11 */
/* AUTHOR : DEEPAK MAHAKALE 3 YEAR IT SRCOEM */
/* BLOG : www.mahakaledeepak.blogspot.com */
/***********************************************************************/
#include<stdio.h>
#include<conio.h>
void main()
{
long int r=0,i=1,odd=0,even=0,no,n,rev=0;
clrscr();
printf("\n\t PROGRAM TO DETECT WHETHER ENTERED NUMBER IS DIVISIBLE BY 11 ");
printf("\n\n\t Enter any number : ");
scanf("%ld",&n);
no=n;
while(no!=0)
{
r=no%10;
rev=rev*10+r;
no=no/10;
}
while(rev!=0)
{
r=rev%10;
if(i%2==0)
{
even=even+r;
}
else
{
odd=odd+r;
}
rev=rev/10;
i++;
}
printf("\n\t Odd sum = %ld \n ",odd);
printf("\n\t Even sum = %ld \n ",even);
if(odd==even)
printf("\n\t %ld Is Divisible by 11",n);
else
printf("\n\t %ld Is Not Divisible by 11",n);
getch();
}
Amazon banner
Sunday, 16 September 2012
PROGRAM TO DETECT WHETHER ENTERED NUMBER IS DIVISIBLE BY 11
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment