#include <stdio.h>
int main()
{
int sum=0, num=0;
while(1)
{
sum+=num; // 0 1 3 6 4950 5050
if(sum>5000) // 5050
break; //break문 실행! 따라서 반복문 탈출
num++;
}
printf("sum: %d \n", sum); // 5050
printf("num: %d \n", num); // 100
return 0;
}
// while(){
// printf(""); ... (1)
// while(){
// printf(""); ... (2)
// if(){ ...(3)
// break; ...(4)
// }
// }
// ... (5)
// if(){ ... (6)
// break; (7)
// }
// }
// ...(8)
To embed this project on your website, copy the following code and paste it into your website's HTML: