added programs

This commit is contained in:
2025-05-21 22:41:44 +09:00
parent ff77070655
commit 3ede55482f
7 changed files with 115 additions and 64 deletions

10
programs/p311/info.json Normal file
View File

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習 3-11",
"description": "論理OR演算子を使用して2つの整数値の差が10以下であるか、11以上であるかを検証するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/p311.png"
},
"note": ""
}

BIN
programs/p311/main Executable file

Binary file not shown.

20
programs/p311/main.c Normal file
View File

@@ -0,0 +1,20 @@
#include <stdio.h>
int main(void) {
int a, b;
printf("Int A: ");
scanf("%d", &a);
printf("Int B: ");
scanf("%d", &b);
int diff = a - b;
if (diff >= 11 || diff <= -11) {
printf("Difference is greater than or equal to 11.\n");
} else {
printf("Difference is less than or equal to 10.\n");
}
return 0;
}