tuantrunghuynh
New member
## Số âm trong C ++
C ++ có một loại tích hợp gọi là `int` đại diện cho các số nguyên.Số nguyên có thể là tích cực, tiêu cực hoặc bằng không.Các số âm được biểu thị bằng dấu trừ (`-`) trước số.Ví dụ, -1 là một số âm.
Bạn có thể sử dụng các toán tử sau để làm việc với các số âm trong C ++:
* `+` Bổ sung
* `-` phép trừ
* `*` Nhân
* `/` Bộ phận
* `%` Mô đun
Ví dụ: mã sau in tổng của hai số âm:
`` `C ++
int a = -1;
int b = -2;
int c = a + b;
cout << c << endl;
`` `
Mã này sẽ in đầu ra sau:
`` `
-3
`` `
Bạn cũng có thể sử dụng các chức năng sau để làm việc với các số âm trong C ++:
* `abs ()` Trả về giá trị tuyệt đối của một số.
* `sign ()` Trả về dấu của một số (1 cho dương, -1 cho âm và 0 cho 0).
* `min ()` Trả về số nhỏ hơn của hai số.
* `Max ()` Trả về hai số lớn hơn.
Ví dụ: mã sau in giá trị tuyệt đối của số âm:
`` `C ++
int a = -1;
int b = abs (a);
cout << b << endl;
`` `
Mã này sẽ in đầu ra sau:
`` `
1
`` `
## hashtags
* #C ++
* #Programming
* #Integers
* #số lượng
* #Loại dữ liệu
=======================================
## Negative number in C++
C++ has a built-in type called `int` that represents integers. Integers can be positive, negative, or zero. The negative numbers are represented by a minus sign (`-`) before the number. For example, -1 is a negative number.
You can use the following operators to work with negative numbers in C++:
* `+` addition
* `-` subtraction
* `*` multiplication
* `/` division
* `%` modulus
For example, the following code prints the sum of two negative numbers:
```c++
int a = -1;
int b = -2;
int c = a + b;
cout << c << endl;
```
This code will print the following output:
```
-3
```
You can also use the following functions to work with negative numbers in C++:
* `abs()` returns the absolute value of a number.
* `sign()` returns the sign of a number (1 for positive, -1 for negative, and 0 for zero).
* `min()` returns the smaller of two numbers.
* `max()` returns the larger of two numbers.
For example, the following code prints the absolute value of a negative number:
```c++
int a = -1;
int b = abs(a);
cout << b << endl;
```
This code will print the following output:
```
1
```
## Hashtags
* #C++
* #Programming
* #Integers
* #negative numbers
* #data types
C ++ có một loại tích hợp gọi là `int` đại diện cho các số nguyên.Số nguyên có thể là tích cực, tiêu cực hoặc bằng không.Các số âm được biểu thị bằng dấu trừ (`-`) trước số.Ví dụ, -1 là một số âm.
Bạn có thể sử dụng các toán tử sau để làm việc với các số âm trong C ++:
* `+` Bổ sung
* `-` phép trừ
* `*` Nhân
* `/` Bộ phận
* `%` Mô đun
Ví dụ: mã sau in tổng của hai số âm:
`` `C ++
int a = -1;
int b = -2;
int c = a + b;
cout << c << endl;
`` `
Mã này sẽ in đầu ra sau:
`` `
-3
`` `
Bạn cũng có thể sử dụng các chức năng sau để làm việc với các số âm trong C ++:
* `abs ()` Trả về giá trị tuyệt đối của một số.
* `sign ()` Trả về dấu của một số (1 cho dương, -1 cho âm và 0 cho 0).
* `min ()` Trả về số nhỏ hơn của hai số.
* `Max ()` Trả về hai số lớn hơn.
Ví dụ: mã sau in giá trị tuyệt đối của số âm:
`` `C ++
int a = -1;
int b = abs (a);
cout << b << endl;
`` `
Mã này sẽ in đầu ra sau:
`` `
1
`` `
## hashtags
* #C ++
* #Programming
* #Integers
* #số lượng
* #Loại dữ liệu
=======================================
## Negative number in C++
C++ has a built-in type called `int` that represents integers. Integers can be positive, negative, or zero. The negative numbers are represented by a minus sign (`-`) before the number. For example, -1 is a negative number.
You can use the following operators to work with negative numbers in C++:
* `+` addition
* `-` subtraction
* `*` multiplication
* `/` division
* `%` modulus
For example, the following code prints the sum of two negative numbers:
```c++
int a = -1;
int b = -2;
int c = a + b;
cout << c << endl;
```
This code will print the following output:
```
-3
```
You can also use the following functions to work with negative numbers in C++:
* `abs()` returns the absolute value of a number.
* `sign()` returns the sign of a number (1 for positive, -1 for negative, and 0 for zero).
* `min()` returns the smaller of two numbers.
* `max()` returns the larger of two numbers.
For example, the following code prints the absolute value of a negative number:
```c++
int a = -1;
int b = abs(a);
cout << b << endl;
```
This code will print the following output:
```
1
```
## Hashtags
* #C++
* #Programming
* #Integers
* #negative numbers
* #data types