#include <stdio.h>
int main(void) {
int num;
do {
// --- 最初の処理 ---
printf("1以上の整数を入力してください: ");
scanf("%d", &num);
if (num < 1) {
printf("エラーです。最初からやり直します。\n\n");
}
// 条件判定:「1以上か?」が No(num < 1)の間は最初に戻る
} while (num < 1);
// Yes(1以上)ならループを抜けて次に進む
printf("正常に入力されました: %d\n", num);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: