0

Yes I know the code is not complete. I know it will cause an infinite loop.

The question is how would I break out of the first for loop and go to the second for loop? Wouldn't using break, break you out of everything? I only wanna break one level.

while(sjn_completion_time_flag != 1)
{
    for(j = 1; j < i; j++)
    {
        if(completed_flag[j] == 0 && completion_time[j] >= arrival_time_array[j])
        {
            printf("completion_time[j]: %d \n",completion_time[j]);
            printf("time_cycles_required_for_job_array[j]: %d \n",time_cycles_required_for_job_array[j]);
            completion_time[j] = completion_time[j] + time_cycles_required_for_job_array[j];
            completed_flag[j] == 1;
            //condition to break
            break;
        }
    }
    //for loop
}
2
Contributors
1
Reply
11
Views
1 Year
Discussion Span
Last Post by overwraith
0

Break only breaks you out of one nested looping structure. So on the inside loop if you break, the inner loop will cease, and the outter loop will continue execution.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.