cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How do you see if a variable is power of
How do you see if a variable is power of 2
Oct 3, 2012 at 2:13pm UTC
vichu99
(10)
Without changing the variable
#include <iostream>
using namespace std ;
int main(){
int a=8;
while(a>2) {
a=a/2;
}
cout<<a << endl;
return 0;
}
Last edited on
Oct 3, 2012 at 2:36pm UTC
Oct 3, 2012 at 2:17pm UTC
Need4Sleep
(570)
Use a temporary variable 'b' to perform calculations on .
Last edited on
Oct 3, 2012 at 2:18pm UTC
Topic archived. No new replies allowed.