Hello
I have this code :
Is there any way to write the function without using a loop?Code:#include <stdio.h> int countSetBits(unsigned char ch) { unsigned int c; for( c = 0; ch; ch >>=1) c += ch & 1; return c; } int main(void) { unsigned char ch; printf("Enter a character: "); scanf(" %c" , &ch); printf(" The number of set bits (1) in character %c is : %d \n" , ch , countSetBits(ch) ); return 0; }