[Dart 기초15] while문

코덩이·2023년 5월 13일
0

Dart

목록 보기
15/18

while

void main() {
// while loop

  int total = 0;

  while (total < 10) {
    total += 1;
  }

  print(total);

// do while 문
  total = 0;

  do {
    total += 1;
  } while (total < 10);

  print(total);

// break를 사용한 경우
  total = 0;

  while (total < 10) {
    total += 1;

    if (total == 5) {
      break;
    }
  }

  print(total);
}

출력결과

10
10
5
profile
개발공부중

0개의 댓글