C language operator

Source: Internet
Author: User

Here, for beginners to the C language of the small partners to introduce several basic operators.  Hope that everyone's study has helped! 1. Arithmetic operator "+ (plus)", "-(minus)", "* (multiply)", "/(except)", "% (take-up)", which focuses on "%" to take the remainder operation, simply lift
instance, 12%5=2, however, be aware that both sides of a symbol must be shaped data.
  2. Shift operator
    << (shift left) ">> (Shift right)", the shift is for 2 decimal digits. The right shift is divided into two cases: arithmetic right shift and logical right SHIFT, arithmetic right shift
Simple generalization: Left fill sign bit, right shift. And the logical right shift is: left 0, right shift. Take 1 as an example to illustrate:
Arithmetic shift

, Logical shift

While the left shift is relatively simple, there is only one case, right 0, left shift.
3. Bitwise operators
  "& (Bitwise AND)" "| (bitwise OR)" "^ Bitwise XOR", for binary number operations, as follows:

3|5=7

  

4. Assignment Operator "="
  To put it briefly, for example, a+=10, that is, A=A+10, both express the same meaning, obviously the former is more concise, we recommend that we use the former in the subsequent programming.
5. Single-Mesh operator (one of the required variables for the operation)
  “! (non) "& (Address)" "sizeof" and so on. Here is a brief introduction to sizeof, commonly used to solve array lengths, such as sizeof (a)
/sizeof (A[0]), but be aware that sizeof is an operator, not a function. In addition, in a nutshell, sizeof is calculated during compilation, and the runtime does not
It's going to be an operation.
6. Relational operators
  "&& (with)" "| | (or) "and so on, where the bitwise operators are distinguished, and the relational operators represent logical operational relationships, such as
0&& (a+10) |26-14, for this equation, see there is a && behind 0, there is no need to look down, because in the computer, this time the operation has stopped, the result
For 0, the same, 1| | (A+10) &&26-14 is 1.
In this, simple for you to introduce the C language operator, I hope you read well, there will be a harvest of Europe!!!

C language operator

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.