loading

Need help regarding code written in keil uvision to print a decimal value on lcd display?

I'm working on project to display the intensity of the bulb.using an ldr.
But while i write a code to convert binary value to its equivalent decimal and call the function the decimal value is not getting displayed when i simulate it in proteous..
Please will u help me in correcting this code.
Thanks in advance.

#include<reg51.h>
#include<math.h>
#include<string.h>
sbit Rs=P1^0;
sbit E=P1^1;
void LCDcmd(unsigned char);
void LCDdata(unsigned int);
void delay(int);
void string_to_lcd(unsigned char *s);
void string_to_lcd2(unsigned char *s);
void main()
{
LCDcmd(0x38); //two lines and 5*7 matrix
  LCDcmd(0x01);//clear display screen
LCDcmd(0x0E);//display on,cursor blinking
//LCDcmd (0x06);//increment cursor shift cursor to right
string_to_lcd("WELCOME");
//LCDdata(11);
LCDcmd(0xC0);//second line
string_to_lcd2("Digit : ");
LCDdata(111);
}
void LCDcmd(unsigned char cmd)
{
  P2=cmd;
  Rs=0;
  E=1;
  delay(100);
  E=0;
  return;
}
void LCDdata(unsigned int n)  //put the value on the pins
{
int i=0,rem,val;
while(n!=0)
  {
rem=n%10;
n/=10;
val+=rem*pow(2,i);
++i;
  }
  P2=val;
  Rs=1;
  E=1;
  delay(100);
  E=0;
return;
}
void delay(int n)
  {
   int i,j;
    for(i=0;i<n;i++)
     for(j=0;j<1000;j++);
  }
void string_to_lcd(unsigned char *s)

{

unsigned char i,l;
l=strlen(s);
for(i=0;i<l;i++)
{
  P2=*s;
  Rs=1;
  E=1;
  delay(100);
  E=0;
delay(100);
s++;
}
return;
}
void string_to_lcd2(unsigned char *lcdstring)
{
unsigned char i,l;
l=strlen(lcdstring);
for(i=0;i<l;i++)
{
 
//LCDcmd(0xC0);//second line
  P2=*lcdstring;
   Rs=1;
  E=1;
  delay(100);
  E=0;
delay(100);
lcdstring++;
}
return;
}