22 lines
351 B
C
22 lines
351 B
C
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
int a, b, i, ans;
|
|
|
|
printf("Input upper limit: ");
|
|
(void)scanf("%d", &a);
|
|
printf("Input lower limit: ");
|
|
(void)scanf("%d", &b);
|
|
|
|
i = b;
|
|
ans = 0;
|
|
|
|
do {
|
|
ans += i++;
|
|
} while (i <= a);
|
|
|
|
printf("Sum of all integer between %d and %d is %d.\n", b, a, ans);
|
|
|
|
return 0;
|
|
}
|