Files
2025-07-09 21:37:36 +09:00

28 lines
418 B
C

#include <stdio.h>
int main(void) {
int a, b, i, ans;
printf("Input integer: ");
(void)scanf("%d", &a);
printf("Input integer: ");
(void)scanf("%d", &b);
if (a < b) {
a = a^b;
b = a^b;
a = a^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;
}