Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Lập Trình C

Các kiểu dữ liệu cơ bản (primary data types) trong C

4 kiểu cơ bản

  • Integer (nguyên)
  • Character (ký tự)
  • Floating-point (thực đơn)
  • Double precision floating-point (thực kép)

Kiểu nguyên (Integral)

Lưu số nguyên và ký tự. Chia: Integer và Character.

Integer Data Types

KiểuKích thước (byte)Phạm viFormat
short int / signed short int1-128 đến 127%h
unsigned short int10 đến 255%uh
int / signed int4-32768 đến 32767%d, %i
unsigned int40 đến 65535%u
long int / signed long int4-2147483648 đến 2147483647%ld
unsigned long int40 đến 4294967295%lu

Character Data Types

KiểuKích thướcPhạm viFormat
char / signed char1-128 đến 127%c
unsigned char10 đến 255%c

Ký tự lưu dưới dạng mã ASCII. VD: 'A' = 65.

Floating-point Data Types

KiểuKích thướcPhạm viFormat
float43.4E-38 đến 3.4E+38%f
double81.7E-308 đến 1.7E+308%lf
long double163.4E-4932 đến 1.1E+4932%Lf