C Program to find whether a number is divisible by ‘11’ or not without actual division

CWC
0 Min Read
#include<stdio.h>
#include<conio.h>
#include<math.h>
main( )
{
int a,b,n,evensum=0,oddsum=0,div;
clrscr( );
printf(“enter a number”);
scanf(“%d”,&n);
a=n;
b=n/10;
while(a>0)
{
oddsum=oddsum+(a%10);
a=a/10;
}
while(b>0)
{
evensum=evensum+(b%10);
b=b/10;
}
div=abs(evensum-oddsum);
if(div%11==0)
printf(“The number is divisible by 11”);
else
printf(“The number is not divisible by
11”);
getch();
}

 

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version