fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 3
  4. int main()
  5. {
  6. int x , y, g;
  7. while (scanf("%d %d", &x, &y)==2)
  8. {
  9. if (x == 0 && y == 0)
  10. break;
  11.  
  12. g = carry(x, y);
  13. if (g == 0) printf("no carry operation\n");
  14. else if (g>0) printf("%d carry operations\n", g);
  15. }
  16.  
  17.  
  18. return 0;
  19. }
  20.  
  21. int carry(int x, int y)
  22. {
  23. int a, b, c, d, e;
  24. int carrynext = 0;
  25. int carry = 0;
  26. a = x;
  27. c = y;
  28. while (a != 0 && c != 0)
  29.  
  30. {
  31.  
  32. b = a % 10;
  33. a = a / 10; /*12*/
  34. d = c % 10; /*3*/
  35. c = c / 10; /*45*/
  36. /*9*/
  37. e = b + d + carrybrkt;
  38.  
  39. if (e >= 10)
  40. {
  41. carry += 1;
  42. carrynext = e / 10;
  43. }
  44. else {
  45. carry += 0;
  46. carrynext = e / 10;
  47. }
  48. }
  49.  
  50.  
  51. return carry;
  52. }
  53.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:12:7: warning: implicit declaration of function ‘carry’ [-Wimplicit-function-declaration]
   g = carry(x, y);
       ^~~~~
prog.c: In function ‘carry’:
prog.c:37:15: error: ‘carrybrkt’ undeclared (first use in this function)
   e = b + d + carrybrkt;
               ^~~~~~~~~
prog.c:37:15: note: each undeclared identifier is reported only once for each function it appears in
prog.c:24:6: warning: variable ‘carrynext’ set but not used [-Wunused-but-set-variable]
  int carrynext = 0;
      ^~~~~~~~~
stdout
Standard output is empty