Bitwise Operators : Bitwise Operators do not operate on decimal value of the Number. They first convert the numbers into binary value & then they operate on it. Bitwise opeartors are not used with floating type variables. Bitwise AND :- & Bitwise OR :- | Bitwise XOR :- ^ Bitwise NOT :- ~ LEFT SHIFT :- << RIGHT SHIFT :- >> Bitwise AND & Example : N1 = 10 , N2 = 15 N1 & N2 In Binary : 0 0 1 0 1 0 0 0 1 1 1 1 ...
Method 1 : #include<stdio.h> int main() { int num =0,sum=0; printf("Enter A Number\n"); scanf("%d",&num); while(num!=0){ sum+=num%10; num/=10; } printf("Sum = %d\n",sum); if(sum%3==0) printf("divisible by 3\n"); else printf("Not Divisible by 3\n"); return 0; }