#include <stdio.h> // 전처리기
int main()
{
// 1~100 까지의 숫자 중 3의 배수는?
for(int i = 1 ; i < 31 ; i++)
{
if (i % 3 == 0)
{
printf("%d는 3의 배수입니다\n", i);
}
}
// break
for ( int j = 0 ; j < 10 ; j++)
{
if (j == 8)
{
break;
}
printf("j = %d\n", j);
}
// break
for ( int j = 0 ; j < 10 ; j++)
{
printf("j = %d\n", j); // printf 위치를 if문 위로 올려봄
if (j == 3)
{
break;
}
}
// continue
for ( int k = 0 ; k < 10 ; k++)
{
if (k == 2)
{
continue; // continue 를 만나는 순간 for 의 증감식(k++)으로 단계를 뛰어라. k=5 제외
}
printf("k = %d\n", k);
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: