Learn C language from scratch 4

Source: Internet
Author: User
Tags bitwise bitwise operators logical operators

Reference book: learn C from scratch

Summary 1. Conditional operators and conditional expressions.   Conditional budget symbol is made by "? "and": "consists of three operands of the conditional operator. The first operand can say any type of expression, such as arithmetic expression  ,   relational expression, assignment expression and logical expression, and the following two expressions are any expressions of the same type. For example, the conditional operator: a? The   of b:c  is: if the logical value of a is true, B is computed, and the result of the operation is generated: if the logical value of a is false, calculate C to generate the result of the operation.   The above example can be concluded that the conditional operator can be used for the judgment and selection of the program. You can use the conditional operator to calculate the value of the larger or   smaller of the two variables very simply. 2. A conditional expression, which is a conditional expression that is formed by a link to a conditional operator. For example, expression 1? Expression 2: Expression 3. The   conditional expression has three operands, all of which are expressions that can say various types of expressions. Typically, expression 1 is a relational expression or a logical expression   used to describe the condition in an expression, depending on whether the condition is true or false to determine whether to perform an operation of expression 2 or an expression 3. Expression 2 and expression 3 can be said to be constant.   variables or expressions such as arithmetic expressions, relational expressions, assignment expressions, and logical expressions.   In general, oh, see, oh, yes. If statements in structural programming can be replaced with each other. For example:   max= (a>b)?a:b;   with if represented as   if (a>b)   {      max=a;  }    else    {       max=b;    } 3. Bitwise operator, Bit operation refers to the binary number bitwise operation, its Operation object is a BITS collection, each bits can only store 0 or 1. The   bit logical operators are bitwise operators that treat 0 or 1 of each bits in the data as logical values and bitwise logical operations. Example of a bitwise logical operation:   ~A: A bitwise negation. A&b: Place A and B in a bitwise phase. A|b: Press A and B to phase or. A^b: The difference between A and B is reduced by a bit. 4. The shift operator includes the left shift operator and the right shift operator, both binocular operators and two operand objects. The first operand is an object to beThe shifted operand,   the second operand is the number of bits moved. For example: A<<b A wants to move the b bit to the left. A>>b shift A to the right by B-bit.   SHIFT operations have a priority of ~ << & ^ | The priority level is from left to right from high to low.

Learn C language from scratch 4

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.