Find if a number is divisible by every number in a list | C ++ program which check is a number divided with every element in list or not ; Function which check is a number divided with every element in list or not ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool findNoIsDivisibleOrNot ( int a [ ] , int n , int l ) { for ( int i = 0 ; i < l ; i ++ ) { if ( a [ i ] % n != 0 ) return false ; } return true ; } int main ( ) { int a [ ] = { 14 , 12 , 4 , 18 } ; int n = 2 ; int l = ( sizeof ( a ) / sizeof ( a [ 0 ] ) ) ; if ( findNoIsDivisibleOrNot ( a , n , l ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }