__builtin_popcount Function For Count 1's in Binary System

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cout << "Enter Normal Integer :: ";
    cin >> n;

    int a = __builtin_popcount(n);

    cout << "Number Of One's :: " << a << "\n";

    long int m;
    cout << "Enter Long Integer :: ";
    cin >> m;

    long int b = __builtin_popcountl(m);

    cout << "Number Of One's :: " << b << "\n";


    long long int l;
    cout << "Enter Long Long Integer :: ";
    cin >> l;

    long long int c = __builtin_popcountll(l);

    cout << "Number Of One's :: " << c << "\n";

    return 0;
}

Comments