When should I use a semicolon in C?

Source: Internet
Author: User

1. In the function body, that is, the content in the braces {}, the function call declaration and the function declaration that requires extra points at the end of the definition of the independent variable: for example, int max (a, B, c) define independent variables: for example, float x and y; 2. Add a plus sign at the end of a sentence (a semicolon is used for the statement used to complete the end), for example, the input and output functions: printf ("a word"); scanf ("a"); 3. After the function is assigned a value, a plus sign is required, for example, c = a * B; z = x + y; 4. The return of the function, that is, the plus points after return, such as return 0; 5. Some special syntaxes do not need to be added, because the execution sequence and result with a semicolon have changed, for example, 1 if (x> y) 2 printf ("x greater than y") in the if statement "); 3 else 4 printf ("y is greater than x"); 5 when x> y is set, execute 2, not set to execute 4, but if you add a semicolon after 1, it will not execute 2 or 4, but execute 5. 6. This part of compilation preprocessing cannot be added! For example, # include <stdio. h> void/int main # include <math. h> # define pi 3.14

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.