while loop for bitwise conversion program int counter(char c){
    int count = 0;
    while (c!=0){
       if((c &amp; 1) !=0)
         count++;
       c = c &gt;&gt; 1;
}
}

I am trying to understand a program that counts the number of 1s in the binary representation of the input character. While I understand the &amp; part and the count part, I don't get why we're checking for c!=0 in the while loop. I know each character is 8 bits. For instance, if the input character is &quot;2&quot; then the binary representation is 10. The count will be 1. So we start by checking the first binary number &quot;1&quot;. Then we shift by 1 and it becomes 01? So then do we check 1 again? Or do we check 0? But if we check 0 then does the while loop not run at all?
An example of the steps would be really helpful.
The &amp; operator is a bitwise &quot;AND&quot;. Since the binary representation of 1 consists only of a 1 on the least significant bit, the operation c &amp; 1 checks if $c$ contains a 1 on the least significant bit. Another way to say it is that c &amp; 1 is the remainder of $c$ modulo 2, that is 0 if $c$ is even and 1 if $c$ is odd.
The &gt;&gt; is a logical shift right, that is the deletion of the least significant bit.
For example, if $c = 26 = (11010)_2$, the steps are:

c &amp; 1 = 0 so count is not modified. $c$ becomes $1101$;
c &amp; 1 = 1 so count is incremented. $c$ becomes $110$;
c &amp; 1 = 0 so count is not modified. $c$ becomes $11$;
c &amp; 1 = 1 so count is incremented. $c$ becomes $1$;
c &amp; 1 = 1 so count is incremented. $c$ becomes $0$.
c != 0 is not true so the algorithm stops. count was incremented thrice, and three is indeed the number of 1's in the binary representation of $c$.