+ 2

# Algorithm

How to create an algorithm that will exclude the first and last digit and add the middle digits For example: 1234 So in this it should exclude 1 and 4 but add 2 and 3 without using String

3 Answers

+ 6

Input: 1234
* Divide the number by 10
So, we now have 123.
That removed the last digit for us.
We now need to make sure our number is greater than or equal to 10, and keep on adding together the next digits.
Get the next digit with: myNum % 10
Steps:
1234 / 10 = 123.
123 > 10, so we keep going.
123 % 10 = 3.
123 / 10 = 12.
12 > 10, so we keep going.
12 % 10 = 2.
12 / 10 = 2.
2 < 10, therefore we are finished.
3 + 2 was 5.

+ 4

Here's the code that does the work :-)
https://code.sololearn.com/cvU0CY2v5HFm/?ref=app

+ 3

take input in form of string. Ignore the first and last characters and then run a loop parse characters and add them.