Completely Solved C, C++ Programs Assignment.




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

Filed Under:

Problem 74. C Program to find whether a number is divisible by ‘11’ or not without actual division.
#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();
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments