int num=5;
while(num>0){
if(num==3)
continue;
printf("%d\n",num);
num--;
}
LOOP 1:
num=5
num>0 yes
num==3 no
prints ==> 5
num-- ==> 4
LOOP 2:
num=4
num>0 yes
num==3 no
prints ==>4
num-- ==>3
LOOP 3:
num=3
num>0 yes
num ==3 yes
continue statement skips the remaining part of the loop(num-- is also skipped ) and returns to beginning of the loop.(note : num=3 )
LOOP 4:
num =3
num> 0 yes
num ==3 yes
DAN SETERUSNYA
====================================
#include <stdio.h>
int main() {
int num = 1;
while (num < 8) {
printf("%d\n", num);
num++;
if (num == 3)
{
break;
}
}
return 0;
}
//break berhenti dengan syarat kondisi if terntu
Tidak ada komentar:
Posting Komentar