I don't understand this code. plz Explain this code in simple words? | Sololearn: Learn to code for FREE!
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)); } }

28th Dec 2018, 5:38 AM
Nitin Gutte
Nitin Gutte - avatar
1 Answer
+ 1
Thank u
28th Dec 2018, 2:34 PM
Nitin Gutte
Nitin Gutte - avatar