-1

I am having a variable name day=3 . I wanted to print on lCD as 03 .concept i am trying to impliment is as below

int term1;
int term2;
int day=3;
term1=day%10;// here i get the actual term day
term2=(int)(day/10). here i get term 0.

Now i wanted to print on lcd by joining term1 and term2.

lcd.print(concat(term1&term2)

question here is how to join term1 and term 2 to get result displayed as 03 instead of 3

RKNAYAK
  • 55
  • 1
  • 3
  • 9

2 Answers2

0

Try this.

lcd.print(term1);
lcd.print(term2);
rmi
  • 532
  • 4
  • 15
0

You can use an array to store values of day

char day_string[3];
int day;
if (day < 10)
{   
    // prepend a 0 to day if day is one digit
    day_string[0]='0';
    day_string[1]=day;
    day_string[2]='\0';
    lcd.print(day_string);
}
else
    // if day is a two digit value print itself 
    lcd.print(day);
Sorcrer
  • 1,634
  • 1
  • 14
  • 27