eolymp
bolt
Try our new interface for solving problems
Problems

The sum of the first and the last digits in the number

published at 1/8/24, 3:18:10 pm

n = abs(int(input())) print(int(str(n)[0])+n%10)

published at 3/20/24, 1:34:21 pm

n = str(abs(int(input()))) print(int(n[:1]) + int(n[int(len(n)-1):]))

published at 4/14/24, 12:46:17 pm

include <iostream>

include <cmath>

using namespace std;

int main() { int n; cin >> n;

int first_digit = abs(n) % 10;
int last_digit = abs(n);
while (last_digit >= 10) {
    last_digit /= 10;
}

int sum = first_digit + last_digit;

cout << sum << endl;

return 0;

}