Please Fill out the Feedback Form for Code Radius

First and Last Digit : FLOW004 | CodeChef Solution

1 min read

Problem

If Give an integer N . Write a program to obtain the sum of the first and last digits of this number.

Input Format

The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains an integer N.

Output Format

For each test case, display the sum of first and last digits of N in a new line.

Constraints

Sample

Input
1234
124894
242323
Output
5
5
5

Solution

cpp
#include <iostream> using namespace std; typedef long long ll; int main() { ll t; cin>>t; while(t--) { ll n,last,first; cin>>n; last=n%10; while(n>=10) { n=n/10; } first=n; cout<<last+first<<"\n"; } return 0; }
Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash …
  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…

Post a Comment