fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3. /* 2016/09/22 */
  4. int first4(int x){
  5. return x/10000;
  6. }
  7. int last4(int x){
  8. /* The operator % in C computes the remainder after division.
  9.   For example, the answer of 23%7 will be 2.*/
  10. return x%10000;
  11. }
  12. int first8(int x){
  13. return x/100000000;
  14. }
  15. int last8(int x){
  16. return x%100000000;
  17. }
  18. int shift4(int x){
  19. return x*10000;
  20. }
  21. int main(void){
  22. int x;
  23. int a, b;
  24. int c1, c2, c3;
  25. /* Assume that the input is always an 8-digit positive integer. */
  26. scanf("%d", x);
  27. a = first4(x);
  28. b = last4(x);
  29. c3 = first8(x);
  30. c2 = last8(x);
  31. c1 = shift4(x);
  32. printf("%d\n",b);
  33. //printf("%4d%08d%04d", ???, ???, ???);
  34. /* %04d will display a 4-digit number and add 0 as padding before the number if necessary */
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5284KB
stdin
8
stdout
0