Dcoder icon

First and the Last Digit @ Dcoder

By Lochard | As a newbie programmer | 30 Apr 2023


Title: First and the Last Digit

Problem: Ron is weak in mathematics.Knowing this fact John challenges him to find the sum of first and last digit of a given number. Help Ron to find the sum of first and last digit of a number.

Input: The first line contains an integer T denoting total number of test cases. 

Then in the following T lines, each line contains an integer N.

 

Output: For each test case, print the sum of first and last digit of N.

Constraints: 1<=T<=100.

10<=N<=100000.

Sample Input: 3

1234

85694

234

Sample Output: 

5

12

6

for t in range(int(input())):
  n = list(input())
  print(int(n[0])+int(n[-1]))

How do you rate this article?

3


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.