Check if a large number is divisible by 5 or not | C ++ program to find if a number is divisible by 5 or not ; Function to find that number divisible by 5 or not . The function assumes that string length is at least one . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isDivisibleBy5 ( string str ) { int n = str . length ( ) ; return ( ( ( str [ n - 1 ] - '0' ) == 0 ) || ( ( str [ n - 1 ] - '0' ) == 5 ) ) ; } int main ( ) { string str = "76955" ; isDivisibleBy5 ( str ) ? cout << " Yes " : cout << " No ▁ " ; return 0 ; }