by Kourt Kourt on June 10th, 2007

Kourt Kourt

Question

Help answer this question below.

One characteristic of the "switch " statement is that all of the statements (inside the switch statement) that follow the matching constant value are executed. What key word shoulde be used to stop the execution of statements after a matching constant?

Answers. Showing one answer.

  • by Fuzzzy on June 25th, 2007

    Fuzzzy

    In the 'C' switch statement, execution continues on into the next case clause if it is not explicitly specified that the execution should exit the switch statement, by using "break".

    For Example:

    switch( Grade )
    {
    case 'A' : printf( "Excellent" );
    break;

    case 'B' : printf( "Good" );
    break;

    case 'C' : printf( "OK" );
    break;

    case 'D' : printf( "Mmmmm...." );
    break;

    case 'F' : printf( "You must do better than this" );
    break;

    default : printf( "What is your grade anyway?" );
    break;
    }

    [ Source: http://www.phim.unibe.ch/comp_doc/c_manual/C/SYNTAX/switch.html ]

    Comments
    • Like
    • Report

    No comments. Post one | Permalink

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

You're reading One characteristic of the "switch " statement is that all of the statements (inside the switch statement) that follow the matching constant value are executed. What key word shoulde be used to stop the execution of statements after a matching constant?

Follow us on Facebook!

Related Ads