|
| 1 | +# If Give an integer N . Write a program to obtain the sum of the first and last digit of this number. |
| 2 | + |
| 3 | +# Input |
| 4 | +# The first line contains an integer T, total number of test cases. Then follow T lines, each line contains an integer N. |
| 5 | + |
| 6 | +# Output |
| 7 | +# Display the sum of first and last digit of N. |
| 8 | + |
| 9 | +# Constraints |
| 10 | +# 1 ≤ T ≤ 1000 |
| 11 | +# 1 ≤ N ≤ 1000000 |
| 12 | +# Example |
| 13 | +# Input |
| 14 | +# 3 |
| 15 | +# 1234 |
| 16 | +# 124894 |
| 17 | +# 242323 |
| 18 | + |
| 19 | +# Output |
| 20 | +# 5 |
| 21 | +# 5 |
| 22 | +# 5 |
| 23 | + |
| 24 | + |
| 25 | +def LastDigit(a): |
| 26 | + return a % 10 |
| 27 | + |
| 28 | + |
| 29 | +def FirstDigit(a): |
| 30 | + # Remove last digit from number |
| 31 | + # till only one digit is left |
| 32 | + while(a >= 10): |
| 33 | + a /= 10 |
| 34 | + return int(a) |
| 35 | + |
| 36 | + |
| 37 | +t = int(input()) |
| 38 | +for i in range(t): |
| 39 | + number = int(input()) |
| 40 | + print(LastDigit(number)+FirstDigit(number)) |
0 commit comments