namereq

2のn乗

Jun 18th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.20 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int num;
  6.     printf("2の何乗(<=30)を求めますか? >");
  7.     scanf("%d",&num);
  8.     if(num >= 31) return -1;
  9.     printf("2^%d = %d\n",num, (1 << num));
  10.     return 0;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment