Attached the output of the program run on ARMSIM.Hover over the headings to see the codes.Once you see the codes the comments will walkthrough the implementation of the code.
#include<iostream>
using namespace std;
int main(){
int r1;
cin>>r1;
bool seq = false;
int count = 0;
while(r1>0){ //to make sure the input value is greater than 0 as we right shift after every iteration
int r = r1&1;
if(r==1){
if(seq==false){
seq = true;
count++;
}
}
else{
if(seq==true){
seq=false;
}
}
r1 = r1>>1;
}
cout<<endl<<count;
return 0;
}





