Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int
  4. main ()
  5. {
  6.   int i, j;
  7.   int n, n1, sum = 0, limit;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.   while (1)
  14.     {
  15.  
  16.       sum = 0;
  17.       scanf ("%d%d", &n, &n1);
  18.  
  19.       if ((n <= 0) || (n1 <= 0))
  20.     {
  21.       break;
  22.     }
  23.  
  24.  
  25.       if (n > n1)
  26.     {
  27.  
  28.  
  29.       for (i = n1; i <= n; i = i + 1)
  30.         {
  31.  
  32.           printf ("%d ", i);
  33.           sum += i;
  34.  
  35.  
  36.  
  37.         }
  38.  
  39.     }
  40.  
  41.  
  42.       else
  43.     {
  44.       for (i = n; i <= n1; i = i + 1)
  45.         {
  46.  
  47.           printf ("%d ", i);
  48.           sum += i;
  49.  
  50.         }
  51.  
  52.     }
  53.  
  54.  
  55.       printf ("Sum=%d\n", sum);
  56.     }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.   return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement