C

The C programming language was devised in the early 1970s by Dennis M. Ritchie an employee from Bell Labs (AT&T). Although originally intended to write Unix kernel, it remains so popular and could be considered a father of almost all modern programming languages we see today.

Example & Compiling
# lets assume there is a file called test.c that looks like this
#include <stdio.h>

int main() {
    printf("Hello AI\n");
    return 0;
}
# we can compile this c program with gcc compiler whose syntax is like this:
SYNTAX: gcc [options] source_files -o output_file
# Compile your file test.c and create an executable output called test
gcc test.c -o test

# To run this program
./test

# Enforce C89 standard with GCC
gcc -std=c89 -pedantic test.c -o test

# Enforce C99 standard with GCC
gcc -std=c99 -pedantic test.c -o test

# Enforce C11 standard with GCC
gcc -std=c11 -pedantic test.c -o test

C Keywords

Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier.

auto        double      int         struct
break       else        long        switch
case        enum        register    typedef
char        extern      return      union
const       float       short       unsigned
continue    for         signed      void
default     goto        sizeof      volatile
do          if          static      while

Placeholders

Placeholder Format
%c Character
%d Signed decimal integer
%i Signed decimal integer
%e Scientific notation [e]
%E Scientific notation [E]
%f Decimal floating point
%o Unsigned octal
%s String of characters
%u Unsigned decimal integer
%x Unsigned hexadecimal (lower)
%X Unsigned hexadecimal (upper)
%p Display a pointer
%% Print a %

Expression & Operators Precedence

Operator Description Associativity
Function Expression () Left to Right
Array Expression [] Left to Right
Structure Operator -> Left to Right
Structure Operator . Left to Right
Unary minus - Right to Left
Increment/Decrement ++, -- Right to Left
One’s compliment ~ Right to Left
Negation ! Right to Left
Address of & Right to Left
Value of address * Right to Left
Type cast (type) Right to Left
Size in bytes sizeof Right to Left
Multiplication * Left to Right
Division / Left to Right
Modulus % Left to Right
Addition + Left to Right
Subtraction - Left to Right
Left shift << Left to Right
Right shift >> Left to Right
Less than < Left to Right
Less than or equal to <= Left to Right
Greater than > Left to Right
Greater than or equal to >= Left to Right
Equal to == Left to Right
Not equal to != Left to Right
Bitwise AND & Left to Right
Bitwise exclusive OR ^ Left to Right
Bitwise inclusive OR | Left to Right
Logical AND && Left to Right
Logical OR || Left to Right
Conditional ?: Right to Left
Assignment =, *=, /=, %=, +=, -=, &=, ^=, |=, <<=, >>= Right to Left
Comma , Right to Left