C Program to Check whether the given Account No is Valid or not..

#include<stdio.h>

void main()
{
 long int n,t,s1=0,s2,sum=0;
 int a[12];
 printf("Enter the account no..");
 scanf("%ld",&n);
 t=n;
 int i=11;
 while(n!=0)
 {
  a[i]=n%10;
  if(i%2!=0)
  {
   s1+=(a[i]);
  }
  else
  {
   a[i]*=2;
   s2=0;
   while(a[i]!=0)
   {
   s2+=a[i]%10;
    a[i]/=10;
   }
   sum+=s2;
  }
  n/=10;
  i--;
 }
 sum+=s1;
 if(sum%10==0)
  printf("\nThe Entered no is a valid Account Number..");
 else
  printf("\nThe Entered no is not a valid Account Number..");
}

No comments:

Post a comment