0
I don't understand this code. plz Explain this code in simple words?
public class Main { public static int sumfirstandlastdigit(int number) { int number1 = number; int sum = 0; if(number < 0) { return -1; } int lastdigit = number % 10; while(number1 != 0) { int firstdigit = number1 / 10; firstdigit = number1; number1 /= 10; sum = firstdigit +lastdigit; } return sum; } public static void main(String args[]) { System.out.println(sumfirstandlastdigit(325)); } }
2 Answers
+ 1
Thank u