Post

C language

An introduction to data types and format specifiers in C language

As I started studying in university, I had to learn C. These are my notes, just in case I forget something, so I can quickly come back and review them.

Data types

Data typeSizeValue range
signed int2 or 4 bytes-32,768 to 32,767
unsigned int2 or 4 bytes0 to 65,535
float4 bytes1.2E-38 to 3.4E+38 (6 decimal places)
double8 bytes2.3E-308 to 1.7E+308 (15 decimal places)
char1 byte-128 to 127
unsigned char1 byte0 to 255

Format specifiers

NameUsage
%d, %iSigned decimal integer
%uUnsigned decimal integer
%fDecimal floating point
%e, %EScientific notation
%g, %GAutomatically chooses %f or %e/%E depending on the value
%cSingle character

Input/output

C language uses functions like printf() and scanf() for input and output:

  • printf(const char *format, ...); — Outputs formatted data.
  • scanf(const char *format, ...); — Reads formatted input.
This post is licensed under CC BY 4.0 by the author.