Check if the number formed by the last digits of N numbers is divisible by 10 or not | C ++ implementation of the approach ; Function that returns true if the number formed by the last digits of all the elements is divisible by 10 ; Last digit of the last element ; Number formed will be divisible by 10 ; Driver code
#include <iostream> NEW_LINE using namespace std ; bool isDivisible ( int arr [ ] , int n ) { int lastDigit = arr [ n - 1 ] % 10 ; if ( lastDigit == 0 ) return true ; return false ; } int main ( ) { int arr [ ] = { 12 , 65 , 46 , 37 , 99 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isDivisible ( arr , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }