C language operator type, C language operator

Source: Internet
Author: User
Tags bitwise operators integer division modulus

C language operator type, C language operator

Arithmetic Operators

Operator

Description

+

Add two operands

-

First operand minus second operand

*

Multiply two operands

/

Numerator divided by denominator

%

Remainder after modulo operation and integer division

++

Incremental operation adds an integer

--

Decrease by an integer

 

Relational operators

Operator

Description

=

Check whether the values of the two operands are equal. If the values are equal, the condition is true.

! =

Check whether the values of the two operands are equal. If the values are not equal, the condition changes to true.

>

Check whether the value of the left operand is greater than the value of the right operand. If yes, the condition is true.

<

Check whether the value of the left operand is smaller than the value of the right operand. If yes, the condition is true.

> =

Check whether the value of the left operand is greater than or equal to the value of the right operand. If yes, the condition is true.

<=

Check whether the value of the left operand is smaller than or equal to the value of the right operand. If yes, the condition is true.

 

Logical operators

Operator

Description

&&

Logic and operators. If both operands are non-zero, the condition is true.

|

Logic or operator. If any two operands are non-zero, the condition is true.

!

The logical non-operator reverses the logic status of the operand. If the condition is true, the logical non-operation result is false.

 

Bitwise operators

Operator

Description

&

Binary AND Operator copies a bit to the result if it exists in both operands.

|

Binary OR Operator copies a bit if it exists in either operand.

^

Binary XOR Operator copies the bit if it is set in one operand but not both.

~

Binary Ones Complement Operator is unary and has the effect of 'flipping' bits.

<

Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.

>

Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.

 

Value assignment operator

Operator

Description

=

Value assignment operator. The value is assigned to the left operand from the right operand.

+ =

Add the value assignment operator, add the Left and Right operands, and assign the result to the left operand.

-=

Subtraction value assignment operator, subtract the Left and Right operations, and assign the result to the left operations

* =

Multiplication and value assignment operators: multiply the Left and Right operands and assign the result to the left operands.

/=

Division assignment operator, Division the Left and Right operations, and assigning the score to the left operations.

% =

Modulus assignment operator, which uses two operands for modulus and assigns the result to the left operand.

<=

Shift left and assign values to operators.

>>=

Shift right and assign values to operators.

& =

Bitwise AND value assignment operators.

^ =

Returns the bitwise exclusive or assigned value operator.

| =

Bitwise OR and value assignment operator.

 

Conditional Operators

Operator

Description

? :

Conditional expression.

 

Comma Operator

Operator

Description

,

It is used to combine several expressions into one expression.

 

Pointer Operator

Operator

Description

&

Returns the address of a variable.

*

The Pointer Points to a variable.

 

Special operators

Operator

Description

Sizeof ()

Returns the variable size.

()

Forced type conversion/(expression)/function (parameter list ).

[]

Array subscript.

.

Member operator.

->

Member operator.

 

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.