We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9393133 commit 3c16a4eCopy full SHA for 3c16a4e
power_of_2.cpp
@@ -0,0 +1,30 @@
1
+/* Program to check whether a given number is a power of 2 using bit-magic /*
2
+
3
4
+#include <iostream>
5
+using namespace std;
6
7
+int main() {
8
+int t;
9
+cin>>t;
10
+while(t--)
11
+{
12
+ long long int n;
13
+ cin>>n;
14
+ if(n==0)
15
+ cout<<"NO";
16
+ else if((n&(-n))==n)
17
+ cout<<"YES";
18
+ else
19
20
21
+ cout<<'\n';
22
23
24
25
26
27
28
+}
29
+ return 0;
30
0 commit comments