draft
This commit is contained in:
21
programs/p42/main.c
Normal file
21
programs/p42/main.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user