C言語
C言語でwhile文を使って繰り返し(ループ)処理を実行する
while文を使用して、繰り返し(ループ)処理を実行します。
while_loop.c
#include <stdio.h>
int main(void) {
int i = 0;
while(i < 5) {
printf("loop count = %d\n", i);
++i;
}
return 0;
}
実行結果
$ gcc while_loop.c -o while_loop
$ ./while_loop
loop count = 0
loop count = 1
loop count = 2
loop count = 3
loop count = 4