Advertisement
18126

Day1(ex5)

Jul 7th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     int num;
  8.     printf("Enter number: ");
  9.     scanf("%d", &num);
  10.     if(num % 2 == 1) {
  11.         printf("Can't divide odd numbers by 2.");
  12.         return -1;
  13.     }
  14.     while(num > 1) {
  15.         if(num / 2 == (num-1) / 2) {
  16.             printf("The operation can't be done. %d is not dividable by 2.", num);
  17.             return -1;
  18.         }
  19.         num = num / 2;
  20.     }
  21.     printf("The operation can be done.");
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement