Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8082883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:16:06+00:00 2026-06-05T17:16:06+00:00

Is there a rule regarding which statements don’t need to be terminated with a

  • 0

Is there a rule regarding which statements don’t need to be terminated with a semicolon?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:16:07+00:00Added an answer on June 5, 2026 at 5:16 pm

    Yes, it’s covered in section 6, “Statement” of the C++ standard (section 6 of C++03, it may have changed in C++11 but I don’t have access to that one at the moment).

    There are a large number of statement types and not all of them need to be terminated. For example, the following if is a selection statement:

    if (i == 1) {
        doSomething();
    }
    

    and there is no requirement to terminate that with a semi-colon.

    Of the different statements covered, the requirements are:

    Statement type        Termination required?
    ==============        =====================
    labelled statement              N (a)
    expression                      Y
    compound statements             N (a)
    selection statements            N (a)
    iteration statements            N (a) (b)
    jump statements                 Y
    declaration statement           Y
    

    (a) Although it may sometimes appear that these are terminated with a semi-colon, that’s not the case. The statement:

    if (i == 1) doSomething();
    

    has the semi-colon terminating the inner expression statement, not the compound statement, somthing that should be obvious when you examine the first code segment above that has it inside {} braces.

    (b) do requires the semi-colon after the while expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a good resource which describes the why behind PMD rule sets? PMD's
Is there any rule about which built-in and standard library classes are not subclassable
There is a rewrite rule ensuring that all URL's head to index.php and maintain
There is a programming rule that says that a method should instead of asking
So there's the Do One Thing rule in the book Clean Code. But how
There is a moment in my app, that I need to force to show
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There is a directed graph having a single designated node called root from which
I find myself in conflict, regarding which code style I should follow when using
Is there some rule of thumb for that decision? I always stuck with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.