Check if a large number is divisible by 20 | CPP program to check if a large number is divisible by 20. ; Get number with last two digits ; Check if the number formed by last two digits is divisible by 5 and 4. ; Driver Program
#include <iostream> NEW_LINE using namespace std ; bool divisibleBy20 ( string num ) { int lastTwoDigits = stoi ( num . substr ( num . length ( ) - 2 , num . length ( ) - 1 ) ) ; return ( ( lastTwoDigits % 5 == 0 ) && ( lastTwoDigits % 4 == 0 ) ) ; } int main ( ) { string num = "63284689320" ; if ( divisibleBy20 ( num ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }