Regarding Ques Playing With Bits

#include<bits/stdc++.h>
using namespace std;
int main()
{
int q,a,b;

cin>>q;
int res[q]={0};

int t=q;
for(int j=0;j<q;j++)
{
    cin>>a>>b;
     int calc=0;
        for(int i=a;i<=b;i++)
        {
            while(i>0)
            {
                calc++;
                i=i & (i-1);
                }
            }
            res[j]=calc;

    }
    for(int i=0;i<t;i++)
    {

        cout<<res[i]<<endl;

} }
This code is not working…please explain why

Plz send your code by saving on ide