draft
This commit is contained in:
10
programs/p42/info.json
Normal file
10
programs/p42/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題2",
|
||||
"description": "教科書の演習4ー2の解答",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p42.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p42/main
Executable file
BIN
programs/p42/main
Executable file
Binary file not shown.
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