Your ideas are good, however the implementation is not so good.
The following code ( please note: I don't claim it is correct :-) ) produces
found 125874 (251748)
as first of such numbers.
#include<stdio.h>
void sort(int a[],int n)
{
int i, j, temp;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if ( a[i] > a[j] )
{
temp = a[i];
a[i] = a[j];
a[j]=temp;
}
}
}
}
int make_array(int x, int a[], int size)
{
int i;
for (i = 0; i < size; ++i)
{
a[i] = x % 10;
x /= 10;
if ( x == 0 ) break;
}
return (i +1);
}
int numcheck(int x)
{
int i;
int sa, sa2;
int a[50], a2[50];
sa = make_array( x, a, 50);
sa2 = make_array( x * 2, a2, 50);
if ( sa != sa2) return 0;
sort( a, sa);
sort( a2, sa);
for(i=0; i<sa; i++)
{
if ( a[i] != a2[i] ) break;
}
if (i != sa) return 0;
return 1;
}
int main()
{
int a,b,i; int t,k;
printf("enter the number of cases\n");
scanf("%d",&t);
for(k=0;k<t;k++)
{
printf("enter the number which are upper bound and lower bound\n");
scanf("%d",&a);
scanf("%d",&b);
for(i=a;i<b;i++)
{
if ( numcheck( i ) == 1) printf("found %d (%d) \n", i, 2*i);
}
}
return 0;
}