Computer Science, asked by nitishamadeshiya, 1 year ago

what is the purpose of using break statement

Answers

Answered by Sriyathmika
2
Hope this may be useful..
The purpose of using break statement is..
break statement in C. When a break statement is encountered inside aloop, the loop is immediately terminated and the program control resumes at the next statementfollowing the loop. It can be used to terminate a case in the switchstatement  pls mark it as the brainliest yaar

nitishamadeshiya: i want in java language
Sriyathmika: u didn't ask that before know
Answered by anjaliom1122
0

Answer:

The processing of a specific case within a switch statement is typically ended using the break statement. An error results from the absence of an enclosed switch or iterative expression.

Explanation:

Break statement:

The nearest enclosing do, for, switch, or while sentence in which it appears is terminated by the break statement. The statement that follows the ended statement receives control.

jump-statement:

   break ;

The processing of a specific case within a switch statement is typically ended using the break statement. An error results from the absence of an enclosed switch or iterative expression.

Only the do, for, switch, or while statement that immediately follows the break statement in nested statements is terminated. To move control outside of the nested structure, use a return or goto command.

This illustration of the break statement is:

#include <stdio.h>

int main()

{

    int num =0;

    while(num<=100)

    {

       printf("value of variable num is: %d\n", num);

       if (num==2)

       {

           break;

       }

       num++;

    }

    printf("Out of while-loop");

    return 0;

}

Similar questions