Fundamentals of Programming: Algorithms, C Language Basics, Tokens, and Operators
Algorithms and Pseudocode
- Algorithm: A step-by-step procedure or set of precise, unambiguous instructions executed in finite time to accomplish a task.
- Derived from the phonetic pronunciation of the last name of Arabic mathematician Abu Ja'far Mohammed ibn Musa al-Khowarizmi.
- Must feature precise inputs, outputs, a start instruction, and a stop instruction without requiring computer-specific code.
- Pseudocode: An informal, artificial English-like language used to plan algorithms prior to coding in target languages like C. It cannot be executed directly on computers.
- Control Constructs:
SEQUENCE: Linear execution of sequential tasks.WHILE: Loop with a condition evaluated at the beginning.REPEAT-UNTIL: Loop with a condition evaluated at the bottom.FOR: Loop governed by iteration bounds.IF-THEN-ELSE: Conditional branching statement.CASE: Generalization of the multi-way IF-THEN-ELSE statement.
Flowcharts
- Flowchart: A diagrammatic tool depicting the step-by-step process flow of a program using geometric shapes connected by arrows.

- Core Symbols & Functions:
- Terminal (Oval / Capsule): Marks the system starting or ending point.
- Process (Rectangle): Represents internal processor, memory, or action steps.
- Input/Output (Parallelogram): Represents data entry or result output operations.
- Decision (Diamond): Asks a binary question resulting in branching paths (Yes/No, True/False).
- Connector (Circle): Connects breaks in a flowchart without intersecting lines or reverse flow.
- Predefined Process: Invokes a subroutine or an interrupt program.
- Preparation (Hexagon): Represents setup prior to another step.
- Flow Lines (Arrows): Indicate direction of flow.
- General Rules:
- Standard direction flows top-to-bottom. Upward flow must not exceed 3 symbols.
- Symbols have an entry point at the top and an exit point at the bottom, except Decision symbols which have two exit points.
C Language Overview and Development Cycle
- Origins: Developed in 1972 at Bell laboratories by Dennis M. Ritchie to implement the UNIX operating system (derived from B / BCPL). First implemented on the DEC PDP-11 computer.
- In 1978, Dennis Ritchie and Brian Kernighan published The C Programming Language ("K & R C").
- ANSI C standard was completed in 1988 (committee formed in 1983).
- Standard Features: Portability, Flexibility, Modularity, Robustness, Extensibility, Efficiency and effectiveness.
- Development Cycle:
- Creating: Code is written using a text editor and saved as a source file.
- Compiling: Compiler translates source file into machine code and checks syntax.
- Linking: Linker combines object code with library functions (e.g., header files like
stdio.h). - Executing: Operating system's Program Loader loads the
.EXE file into RAM for run-time execution.
- C vs C++ Differences:
- C: Procedural programming language; no support for OOPs, function overloading, operator overloading, or access control mechanisms. Uses manual memory management (
malloc(), calloc(), free()). - C++: Supports Procedural, Object-Oriented, and Generic paradigms. Supports OOPs concepts, function overloading, operator overloading, access control keywords (
private, public, protected), and automatic/manual memory handling (new, delete).
C Tokens, Identifiers, and Data Types

- Tokens: Smallest individual building blocks recognized by the compiler:
- Keywords: 32 pre-defined, reserved lowercase words performing specific system functions (e.g.,
int, return, void, if, while). - Identifiers: Custom names assigned to variables, functions, and arrays. Must begin with an alphabet or underscore (
_), contain only alphanumeric characters, and are case-sensitive. - Variables: Named memory locations storing dynamic values. Must be declared before use.
- Basic Data Types:
int (%d or %i): Whole integer numbers.float (%f): Real numbers with decimal points.double (%f): Large numbers with decimal points.char (%c): Single letter/symbol enclosed in single quotes.char array (%s): Series of characters forming a string enclosed in double quotes.
C Operators
- Arithmetic:
+ (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulo division for remainder). - Relational:
== (Equal to), > (Greater than), < (Less than), != (Not equal to), >= (Greater than or equal to), <= (Less than or equal to). Returns true (1) or false (0). - Logical:
&& (Logical AND), || (Logical OR), ! (Logical NOT). - Bitwise / Binary:
& (AND), | (OR), ^ (EX-OR), ~ (Bitwise complement: −(n+1)).<< (Left shift): Left shifting once multiplies value by 2.>> (Right shift): Right shifting once divides value by 2.
- Assignment:
=, +=, -=, *=, /=, %=, <<=, >>=, &=, |=, ^=. - Increment / Decrement:
++operand (Unary pre-increment): Increments value first, then assigns.--operand (Unary pre-decrement): Decrements value first, then assigns.operand++ (Unary post-increment): Assigns value first, then increments.operand-- (Unary post-decrement): Assigns value first, then decrements.