Computer Science, asked by keshavpaudel141, 11 months ago

write a java script code to check the first digit of number

Answers

Answered by akashjain135
0

HERE IS YOUR ANSWER MATE ----

firstDigit = number/((int)(pow(10,(int)log(number)))); This should get your first digit using math instead of strings. int number = 534; int firstDigit = number/100; ( / ) operator in java divide the numbers without considering the reminder so when we divide 534 by 100 , it gives us (5) .

HOPE IT HELPS YOU

Similar questions