Skip to content

Commit 1decf7a

Browse files
authored
Create Lecture - 31.cpp
1 parent 7cb846b commit 1decf7a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Lecture - 31.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// main.cpp
3+
// lecture 31
4+
//
5+
// Created by Prince Kumar on 04/04/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// --- * Check the number is power of 2 * --- //
9+
#include <iostream>
10+
using namespace std;
11+
int main()
12+
{
13+
cout<<"Enter the number "<<endl;
14+
int x;
15+
cin>>x;
16+
int a = x & (x-1);
17+
if(a==0)
18+
cout<<"Number is the power of 2"<<endl;
19+
else
20+
cout<<"Number is NOT the power of 2"<<endl;
21+
22+
}

0 commit comments

Comments
 (0)