Home >Backend Development >C++ >How to calculate int in c language
Overview of int type calculation rules in C language: Arithmetic operators: addition, subtraction, multiplication, division, remainder, self-increment, self-decrement Assignment operators: assignment, addition, subtraction, multiplication, division, remainder, remainder, assignment comparison operators: equal to not equal to less than greater than less than equal to greater than equal to Logical operators: logical AND logical or logical NOT Bit operators: bit AND bit or bit XOR bit left shift right shift
C language Calculation of int type
int is the basic data type representing integer in C language and occupies 4 bytes in the computer. Its calculation rules are as follows:
Arithmetic operators:
Assignment operator:
Comparison operator:
Logical operators:
bit operator:
Bit shift right
<code class="c">int a = 10;
int b = 5;
int c;
c = a + b; // c 为 15
c = a - b; // c 为 5
c = a * b; // c 为 50
c = a / b; // c 为 2.0(实数)
c = a % b; // c 为 0
c++; // c 为 11
c--; // c 为 10</code>
The above is the detailed content of How to calculate int in c language. For more information, please follow other related articles on the PHP Chinese website!