C언어
2020.05.08 / Day - 26 C언어 반복문
개발지혜
2020. 5. 8. 18:31
26일차
while문
// 기본개념
// while => ~~ 할 때 동안 계속
// while => ~~ 가 참일 때 동안 계속
// while => if문 똑같다. 단 무한실행 if문 이다.
#include <stdio.h>
int main(void) {
int i = 1;
while ( i <= 10 ) {
printf("%d\n", i);
i++;
}
return 0;
}
출력 : 1 2 3 4 5 6 7 8 9 10
for문
#include <stdio.h>
int main(void) {
for ( int i = 1; i <= 10; i++ ) {
printf("%d\n", i);
}
return 0;
}
출력 : 1 2 3 4 5 6 7 8 9 10