#include <stdio.h>

int main() {
    int a = 10; // 1010

    int count = 0;
    int temp_a = a; // Create a copy of 'a'

    while (temp_a) {
        if (temp_a & 1) {
            count++;
        }
        temp_a = temp_a >> 1;
    }

    printf("%d\n", count);
    printf("%d\n", a); // 'a' remains unchanged
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: