fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. cout<<"program for finding the number is square or not\n ";
  7. cout<<"enter the number\n";
  8. int num;
  9. cin>>num;
  10. int rem,result;
  11. if(num==1){
  12. result=1;
  13. }else{
  14. while(num){
  15. rem=num&1;
  16. num=num/10;
  17.  
  18. if(rem==1){
  19. result=0;
  20. }else{
  21. result=1;
  22. }
  23. }
  24. }
  25.  
  26. if(result==1){
  27. cout<<"the number is in power of two\n";
  28.  
  29. }else{
  30. cout<<"the number is not in power of two\n";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5272KB
stdin
12
stdout
program for finding the number is square or not
 enter the number
the number is not in power of two