Check if a number ends with another number or not | C ++ program for the above approach ; Function to check if B is a suffix of A or not ; Convert numbers into strings ; Check if s2 is a suffix of s1 or not using ends_with ( ) function ; If result is true , print " Yes " ; Driver Code ; Given numbers ; Function Call
#include <bits/stdc++.h> NEW_LINE #include <boost/algorithm/string.hpp> NEW_LINE using namespace std ; void checkSuffix ( int A , int B ) { string s1 = to_string ( A ) ; string s2 = to_string ( B ) ; bool result ; result = boost :: algorithm :: ends_with ( s1 , s2 ) ; if ( result ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { int A = 12345 , B = 45 ; checkSuffix ( A , B ) ; return 0 ; }