If I have an array of years for example 1974 1948 1999 1989
Solution
Answer
i. Take each year from the array and initialize sum to 0
ii. using modulus method, fetch the last digit, i.e. remender = n % 10; this will give you the last digit
iii. check if it is the digit you want
iv. if yes then add this year to sum
v. else, ignore
vi. repeat steps ii to v for all the elements of the array
