← C Programming learning path
C Programming · Module 2 of 10

Variables, data types and I/O

Store values in typed variables and read input with scanf.

📖 Key ideas

  1. Common types: int (whole numbers), float/double (decimals), char (one character).
  2. Declare before use: int age = 20;
  3. printf uses format codes: %d int, %f float, %c char, %s string.
  4. scanf("%d", &age); reads a number into age (note the &).
  5. sizeof(int) tells the size in bytes.
💡 Real-life example: Data types are containers of fixed sizes: a cup (char), a bottle (int), a jug (double).
intWhole number type
charSingle character type
%dFormat code for int
&Address-of operator used with scanf