keerthikampc
Newbie level 4

how to display the message of x in lcd,where x=a/98*100,a is the input
x=(a*100)/98;
dig1 = x/1000;
dig2 = (x/100) % 10;
dig3 = (x/10) % 10;
dig4 = x % 10;
dig1 = dig1 + 48;
dig2 = dig2 + 48;
dig3 = dig3 + 48;
dig4 = dig4 + 48;
First get the value of x:
Code:x=(a*100)/98;
I'm assuming x is a 4-digit integer.
Get the digits:
Code:dig1 = x/1000; dig2 = (x/100) % 10; dig3 = (x/10) % 10; dig4 = x % 10;
Then convert them to ASCII:
Code:dig1 = dig1 + 48; dig2 = dig2 + 48; dig3 = dig3 + 48; dig4 = dig4 + 48;
You can get the digits and convert to ASCII in one line of code if you want.
Then send the digits dig1, dig2, dig3, dig4 to LCD.
Hope this helps.
Tahmid.