Share phép toán số học trong c++

dangquang646

New member
## Hoạt động số học trong C ++

C ++ là một ngôn ngữ lập trình mạnh mẽ được sử dụng cho nhiều ứng dụng khác nhau.Một trong những khía cạnh quan trọng nhất của C ++ là các hoạt động số học của nó.Các hoạt động này cho phép bạn thực hiện các tính toán trên các số và biến.

Có một số hoạt động số học khác nhau mà bạn có thể thực hiện trong C ++.Chúng bao gồm bổ sung, trừ, nhân, chia và mô đun.

**Phép cộng**

Toán tử bổ sung được sử dụng để thêm hai số hoặc biến với nhau.Cú pháp để bổ sung như sau:

`` `
a + b
`` `

Trong đó `A` và` B` là hai số hoặc biến mà bạn muốn cộng lại.

Ví dụ: mã sau sẽ thêm các số 10 và 20 cùng nhau:

`` `
int a = 10;
int b = 20;
int c = a + b;
`` `

Giá trị của `C` sẽ là 30.

** Phép trừ **

Toán tử trừ được sử dụng để trừ một số hoặc biến từ một số khác.Cú pháp cho phép trừ như sau:

`` `
a - b
`` `

trong đó `A` là số hoặc biến mà bạn đang trừ đi và` B` là số hoặc biến mà bạn đang trừ.

Ví dụ: mã sau sẽ trừ số 10 khỏi số 20:

`` `
int a = 20;
int b = 10;
int c = a - b;
`` `

Giá trị của `C` sẽ là 10.

**Phép nhân**

Toán tử nhân được sử dụng để nhân hai số hoặc biến với nhau.Cú pháp để nhân như sau:

`` `
a * b
`` `

Trong đó `A` và` B` là hai số hoặc biến mà bạn muốn nhân với nhau.

Ví dụ: mã sau sẽ nhân số 10 và 20 với nhau:

`` `
int a = 10;
int b = 20;
int c = a * b;
`` `

Giá trị của `C` sẽ là 200.

**Phân công**

Toán tử phân chia được sử dụng để chia một số hoặc biến cho một số khác.Cú pháp cho bộ phận như sau:

`` `
a / b
`` `

trong đó `A` là số hoặc biến mà bạn đang chia và` B` là số hoặc biến mà bạn đang chia.

Ví dụ: mã sau sẽ chia số 20 cho số 10:

`` `
int a = 20;
int b = 10;
int c = a / b;
`` `

Giá trị của `C` sẽ là 2.

** Mô đun **

Toán tử mô đun được sử dụng để tìm phần còn lại khi một số hoặc biến được chia cho một số khác.Cú pháp cho mô đun như sau:

`` `
một % b
`` `

trong đó `A` là số hoặc biến mà bạn đang chia và` B` là số hoặc biến mà bạn đang chia.

Ví dụ: mã sau sẽ tìm thấy phần còn lại khi số 20 được chia cho số 10:

`` `
int a = 20;
int b = 10;
int c = a % b;
`` `

Giá trị của `C` sẽ là 0.

## hashtags

* #C ++
* #các phép tính toán học
* #Programming
* #phép cộng
* #SubTraction
* #phép nhân
* #Phân công
* #Modulus
=======================================
## Arithmetic operations in C++

C++ is a powerful programming language that is used for a wide variety of applications. One of the most important aspects of C++ is its arithmetic operations. These operations allow you to perform calculations on numbers and variables.

There are a number of different arithmetic operations that you can perform in C++. These include addition, subtraction, multiplication, division, and modulus.

**Addition**

The addition operator is used to add two numbers or variables together. The syntax for addition is as follows:

```
a + b
```

where `a` and `b` are the two numbers or variables that you want to add together.

For example, the following code would add the numbers 10 and 20 together:

```
int a = 10;
int b = 20;
int c = a + b;
```

The value of `c` would be 30.

**Subtraction**

The subtraction operator is used to subtract one number or variable from another. The syntax for subtraction is as follows:

```
a - b
```

where `a` is the number or variable that you are subtracting from, and `b` is the number or variable that you are subtracting.

For example, the following code would subtract the number 10 from the number 20:

```
int a = 20;
int b = 10;
int c = a - b;
```

The value of `c` would be 10.

**Multiplication**

The multiplication operator is used to multiply two numbers or variables together. The syntax for multiplication is as follows:

```
a * b
```

where `a` and `b` are the two numbers or variables that you want to multiply together.

For example, the following code would multiply the numbers 10 and 20 together:

```
int a = 10;
int b = 20;
int c = a * b;
```

The value of `c` would be 200.

**Division**

The division operator is used to divide one number or variable by another. The syntax for division is as follows:

```
a / b
```

where `a` is the number or variable that you are dividing, and `b` is the number or variable that you are dividing by.

For example, the following code would divide the number 20 by the number 10:

```
int a = 20;
int b = 10;
int c = a / b;
```

The value of `c` would be 2.

**Modulus**

The modulus operator is used to find the remainder when one number or variable is divided by another. The syntax for modulus is as follows:

```
a % b
```

where `a` is the number or variable that you are dividing, and `b` is the number or variable that you are dividing by.

For example, the following code would find the remainder when the number 20 is divided by the number 10:

```
int a = 20;
int b = 10;
int c = a % b;
```

The value of `c` would be 0.

## Hashtags

* #C++
* #arithmetic operations
* #Programming
* #Addition
* #SubTraction
* #MultipLication
* #Division
* #Modulus
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top