Check if a large number is divisible by 9 or not | C ++ program to find if a number is divisible by 9 or not ; Function to find that number divisible by 9 or not ; Compute sum of digits ; Check if sum of digits is divisible by 9. ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int check ( string str ) { int n = str . length ( ) ; int digitSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) digitSum += ( str [ i ] - '0' ) ; return ( digitSum % 9 == 0 ) ; } int main ( ) { string str = "99333" ; check ( str ) ? cout << " Yes " : cout << " No ▁ " ; return 0 ; }