Your Ad Here

Posted By

A4i on 12/24/11


Tagged

numbers 2 increase decrease Tow


Versions (?)

IncDec2Numbers


 / Published in: C
 

This Code is only for Windows because of getch(); It Increase or Decrease tow number. Depending on which button you press '+' or '-'.

  1. // Only for Windows because of getch();
  2.  
  3. #include <stdio.h>
  4.  
  5. int main()
  6. {
  7. int i, x, y;
  8. char action;
  9.  
  10. Begin:
  11.  
  12. printf("Enter the x: ");
  13. scanf("%d", &x);
  14. getchar();
  15.  
  16. printf("Enter the y: ");
  17. scanf("%d", &y);
  18. getchar();
  19.  
  20. do
  21. {
  22. printf("x, y = %d, %d\n", x, y);
  23. action = getch();
  24. if(action == '+')
  25. {
  26. x++;
  27. y++;
  28. }
  29. else if(action == '-')
  30. {
  31. x--;
  32. y--;
  33. }
  34. }
  35. while((action == '-') || (action == '+'));
  36.  
  37. goto Begin;
  38.  
  39. getchar();
  40. return 0;
  41. }

Report this snippet  

You need to login to post a comment.