C++ Program to find whether a number is divisible by ‘11’ or not without actual division
#include
#include
#include
#include
using namespace std;
int main( )
{
int a,b,n,evensum=0,oddsum=0,div;
cout<<"enter a number"; cin>>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)cout<<"The number is divisible by 11";
else cout<<"The number is not divisible by 11";
return 0;
}