hiiiiiiii,

this program is about "FINDING THE 9 DIGIT NUMBER in which the number formed by leftmost two digits is divisible by 2,the number formed by left most three digits is divisible by 3 and SO on.......&at last the number is divisible by 9.......The condition is

no digit is used more than once"

Though i tried this program,i was not able to get the number which i deserved to get.

the main problem that i am facing is i am not able to check whether all the digits in the number are different.

Can any one of you help me this regard.

the code is:

#include <stdio.h>

#include <math.h>

void main()

{

bool bvalid = true;

long l =0;

long lMax = 2147483647;//Long.MAX_VALUE;

long l1 =0,l2 =0,l3 =0,l4 =0,l5 =0,l6 =0,l7 =0,l8 =0,l9 =0;

for (l=123456789 ; l < 987654321 ; l++ )

{

l1 = floor(l/100000000);

l2 = floor(l/10000000) - (l1*10) ;

l3 = floor(l/1000000) - (l1*100 + l2*10);

l4 = floor(l/100000) - (l1*1000 + l2*100 + l3*10);

l5 = floor(l/10000) - (l1*10000 + l2*1000 + l3*100 + l4*10);

l6 = floor(l/1000) - (l1*100000 + l2*10000 + l3*1000 + l4*100 + l5*10);

l7 = floor(l/100) - (l1*1000000 + l2*100000 + l3*10000 + l4*1000 + l5*100 + l6*10);

l8 = floor(l/10) - (l1*10000000 + l2*1000000 + l3*100000 + l4*10000 + l5*1000 + l6*100 + l7*10);

l9 = floor(l/1) - (l1*100000000 + l2*10000000 + l3*1000000 + l4*100000 + l5*10000 + l6*1000 + l7*100 + l8*10);

long larr[9];

larr[0] = l1;

larr[1] = l2;

larr[2] = l3;

larr[3] = l4;

larr[4] = l5;

larr[5] = l6;

larr[6] = l7;

larr[7] = l8;

larr[8] = l9;

bvalid = true;

for(int i = 0 ; i < 9 ; i++)

{

int temp = larr[i];

for(int j = 0; j < 9 ; j++)

{

if( temp == larr[j] && (i != j) )

{

bvalid = false;

break ;

}

}

if(bvalid == false)

break;

}

if( bvalid != false)

{

if( (l1 !=0) && (l2 !=0) && (l3 !=0) &&(l4 !=0) &&(l5 !=0) &&(l6 !=0) &&(l7 !=0) &&(l8 !=0) &&(l9 !=0) &&

(l5 == 5) && ( fmod((l1*10 + l2),2) == 0 ) &&

( fmod((l1*100 + l2*10 + l3),3) == 0 ) &&

( fmod((l1*1000 + l2*100 + l3*10 + l4),4) == 0 ) &&

( fmod((l1*10000 + l2*1000 + l3*100 + l4*10 + l5),5) == 0 ) &&

( fmod((l1*100000 + l2*10000 + l3*1000 + l4*100 + l5*10 + l6),6) == 0 ) &&

( fmod((l1*1000000 + l2*100000 + l3*10000 + l4*1000 + l5*100 + l6*10 + l7),7) == 0 ) &&

( fmod((l1*10000000 + l2*1000000 + l3*100000 + l4*10000 + l5*1000 + l6*100 + l7*10 + l8),8) == 0 ) &&

( fmod((l1*100000000 + l2*10000000 + l3*1000000 + l4*100000 + l5*10000 + l6*1000 + l7*100 + l8*10 + l9),9) == 0)

)

{

printf("satisfied %d \n",l);

}

//printf(" for %d value...requirement not satisfying", l);

}

}