text: Count numbers with unit digit k in given range | Simple CPP program to count numbers with last digit as k in given range . ; Returns count of numbers with k as last digit . ; Driver Program
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int counLastDigitK ( int low , int high , int k ) { int count = 0 ; for ( int i = low ; i <= high ; i ++ ) if ( i % 10 == k ) count ++ ; return count ; } int main ( ) { int low = 3 , high = 35 , k = 3 ; cout << counLastDigitK ( low , high , k ) ; return 0 ; }