Q:

C Program To Check Number Is Divisible By 11 Or Not Using (VEDIC MATH)

belongs to collection: Loops C Programs for Practice

0

Write A C Program To Check Number Is Divisible By 11 Or Not Using (VEDIC MATH)

 

Logic : Here Is A Clarification Of  Below Program If We Want To Check Any No Is Divisible By 11 Or Not Its Very Simple You Have To Calculate Even And Odd Place Sum If Both Are Shame The No Also Will Be Divisible By 11 If Not Equal Then NOT Divisible By Now Check Code

Example :
So take a Example 161051
 
So Add Even place and odd Place Numbers 
 
Even :- 6+0+1=7
 
Odd :- 1+1+5=7
 
Now Compare Even Or Odd Number addition If Both Are Equal then Number is Divisible Else Not .
 
If you got a Solution then Try Below Problems .

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<conio.h>
void main()
{
    long int r=0,i=1,odd=0,even=0,no,n,rev=0;
  
  while(1)
  {
    printf("\n\nEnter 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("\nOdd Digit sum = %ld \n ",odd);
    printf("\nEven Digit Sum = %ld \n ",even);

    if(odd==even)
     printf("\n%ld Is Divisible by 11\n\n",n);
    else
     printf("\n%ld Is Not Divisible by 11\n\n",n);
 }
    getch();

}

 

Output:

Enter Any Number : 161051

Odd Digit sum=7

Even Digit sum=7

161051 Is Divisbale by 11

Enter Any Number 123

Odd Digit sum =11

Even Digit sum=9 

123 Is Not Divisbale by 11

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program For Sort A Float Array In Acceding And D... >>
<< C Program To Generate IP Addresses (Internet Proto...