All submissions

Count Set Bits in an 8-bit Register

Code

#include<stdio.h>
int main(){
   int reg,count=0,pos=0 ;
   scanf("%d",&reg);
while(pos<32){
if (reg &(1<<pos))
   {
    count++;
   }
   pos++;
}
   
   printf("%d",count);

    return 0;
}

Solving Approach

 

 

 

Loading...

Input

0

Expected Output

0