Skip to content

Commit fbd02ae

Browse files
authored
Create First_set_bit.cpp
Program to find first set bit from right side in binary representation of a number
1 parent 9393133 commit fbd02ae

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: First_set_bit.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Program to find first set bit from right side in binary representation of a number. /*
2+
3+
#include <iostream>
4+
#include <bits/stdc++.h>
5+
using namespace std;
6+
7+
int main() {
8+
int t;
9+
cin>>t;
10+
while(t--)
11+
{
12+
int n;
13+
cin>>n;
14+
unsigned int v=log2(n&-n)+1;
15+
cout<<v<<'\n';
16+
17+
}
18+
19+
20+
21+
return 0;
22+
}

0 commit comments

Comments
 (0)