A to Z Modulo Operator Usage

·

1 min read

a-f: These are for floating-point numbers (decimals):

  • %a: Scientific notation (e.g., 1.234e5)

  • %b: Binary exponent notation (e.g., 1.0101101e010)

  • %c: Character

  • %d: Integer

  • %e: Scientific notation with lowercase exponent (e.g., 1.234e-5)

  • %f: Fixed-point notation (e.g., 1.2345)

g-p: These are also for floating-point numbers, but with more options:

  • %g: Automatic selection of %e or %f (whichever is shorter)

  • %h: Half-precision floating-point (not widely used)

  • %i: Integer (equivalent to %d but prints with sign)

  • %j: Imaginary unit (for complex numbers)

  • %k: Integer (equivalent to %d but prints with thousands separators)

  • %l: Long integer (not applicable for floating-point)

  • %m: Pointer address (not common use)

  • %n: Number of characters written (used for internal purposes)

  • %o: Octal (base-8)

  • %p: Pointer address

  • %q: Hexadecimal with quotes (e.g., "0x1234")

  • %r: Character sequence (rarely used)

  • %s: String

  • %t: Character (tab)

  • %u: Unsigned integer

x-z: These are mostly extensions and not standard in C:

  • %v: GNU extension for verbose printf (prints variable information)

  • %w: Wide character (not common)

  • %y: Year (2-digit format)

  • %z: Size of stack required for format specifier (obscure use)