Conditional Statement C

Source: Internet
Author: User

I. Conditional statements are general-speaking selection structures

Select Structure-

if statement ;

    1. First structure: if (condition) {statement 1; Statement 2; ...}
    2. Second structure: if (condition) {statement 1; Statement 2; ...} else{statement 3; statement 4; ...}
    3. Third structure: if (condition) {statement 1; Statement 2; ...} else if (condition 2) {statement 3; statement 4; ...} else if (condition 3) {statement 4; statement 3; ...} else if (condition 4) {statement 4; statement 3; ...} else{statement 4; statement 3; ...}
    4. The fourth structure: if (conditional) statement 1; no curly braces; The preceding conditional statement is over; if there is a statement 2, it is not related to if;
    5. Note: If use NOTE: Any numeric value is true or false; int a = 10;if (A = 0) {} Where a =0 is an assignment operation, we cannot use it here, we are judging whether a is equal to 0, rather than assigning a value to A; To avoid this error can be written if (0 = = a) {} , you can avoid yourself less = number;
    6. judge whether the value is equal, write the constant value to the left;
    7. Note that the assignment operator has only one equal sign, not two equals sign; = = is a relational operator;
    8. Cannot write: if (10>6) int a = 5; without curly braces, the scope of int A is not known; the scope of the code is ambiguous;
    9. Because int A is behind if, it is limited to the IF statement, but the if scope is ambiguous;
    10. Writing format:

switch Statement ;

      1. structure: switch (value) {}
      2. break is the exit switch function; return exits the main function;
      3. break importance: If there is no break after the case, You will be executed in all of the following case, until you encounter a break; if the case is judged once, the subsequent conditions will not be judged if there is no break at the back;
      4. if in the implementation of the size of the comparison, switch can not do, switch inside the function can be achieved in the if can be achieved;
      5. 1), Bytes and addresses: 1GB how many bytes: Each byte has its own address;
        2), the larger the data, The larger the bytes to take up,
        3), the memory addressing from large to small,
        4), the address of the variable is the smallest of the bytes, the more defined the variable, the greater the memory address, the   
        5), & is the address operator; used to get the variable;
        6), Assign the following address to the previous variable,%p is the address of the output variable,
        7), the variable is not initialized, and it is incorrect to use;


scanf function:
1), and the printf function opposite; this is the input; let the user enter;
2), when using scanf, take the address &; space symbol is \

Conditional Statement C

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.