Determine whether the given integer N is a Peculiar Number or not | C ++ implementation to check if the number is peculiar ; Function to find sum of digits of a number ; Function to check if the number is peculiar ; Store a duplicate of n ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sumDig ( int n ) { int s = 0 ; while ( n != 0 ) { s = s + ( n % 10 ) ; n = n / 10 ; } return s ; } bool Pec ( int n ) { int dup = n ; int dig = sumDig ( n ) ; if ( dig * 3 == dup ) return true ; else return false ; } int main ( ) { int n = 36 ; if ( Pec ( n ) == true ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }