1
0

lesser.c 573 B

12345678910111213141516171819202122232425262728293031
  1. /* lesser.c -- finds the lesser of two evils */
  2. #include <stdio.h>
  3. int imin(int, int);
  4. int main(void)
  5. {
  6. int evil1, evil2;
  7. printf("Enter a pair of integers (q to quit):\n");
  8. while (scanf("%d %d", &evil1, &evil2) == 2)
  9. {
  10. printf("The lesser of %d and %d is %d.\n",
  11. evil1, evil2, imin(evil1,evil2));
  12. printf("Enter a pair of integers (q to quit):\n");
  13. }
  14. printf("Bye.\n");
  15. return 0;
  16. }
  17. int imin(int n,int m)
  18. {
  19. int min;
  20. if (n < m)
  21. min = n;
  22. else
  23. min = m;
  24. return min;
  25. }