Introduction to Computer Systems, Programming Languages, and C Fundamentals
Fundamentals of Computer Systems
Definition of a Computer System: An electronic device that performs operations by accepting data as input, storing data, manipulating or processing data according to set instructions, and producing results as output in a human-understandable format.
Core Operations Performed by a Computer:
Accepts input data from peripheral devices or files.
Processes or manipulates the data using a Central Processing Unit ().
Displays or stores the results in human-understandable output formats.
Stores data, instructions, and computation results in primary and secondary memory.
Primary Categorization of Computer Components:
Hardware: Physical electronic, electromechanical, and electromagnetic devices.
Software: Set of programs, commands, and data instructions that direct the hardware.

Computer Hardware and Software
Computer Hardware:
Consists of the bare machinery, physical electronic components, electro-mechanical parts, and electromagnetic devices connected via interfacing data/address buses.
Core hardware components include:
Central Processing Unit () & Fan: Performs core processing and arithmetic operations.
Mainboard / Motherboard: Connects all internal electronic components and buses.
Random Access Memory (): Volatile primary storage for running programs.
Hard Disk Drive (): Non-volatile secondary storage for data and software.
Power Supply Unit (): Supplies regulated electrical power to internal hardware.
VGA Card / Sound Card: Expansion cards for graphic and audio processing.
Optical Drive () & Internal All-in-One Reader: Media input drives.
Peripherals: Monitor, Keyboard, Mouse, and Speakers.

Computer Software:
Consists of instructions, code commands, computer programs, and structured data held in memory storage that direct hardware operations.
Analogy: Hardware represents the physical body of a computer system, whereas software represents its soul. Both are indispensable for operation.

Categories of Software:
Application Software: Software developed to assist users in executing end-user tasks benefiting from computation. Subcategories include:
Business software and accounting packages (e.g., Tally/ERP 9, QuickBooks).
Computer-Aided Design () software (e.g., SolidWorks).
Database Management Systems ().
Web browsers (e.g., Google Chrome, Safari, Microsoft Edge).
Media players (e.g., VLC Media Player) and graphics editing tools (e.g., Adobe Photoshop, Illustrator).
Educational, medical ( systems), and decision-making applications.

System & Programming Software: Specialized programs used by software engineers to write, edit, test, debug, and build other programs. Examples include:
Compilers and Interpreters (e.g., GCC compiler).
Integrated Development Environments () such as Visual Studio, Code::Blocks, and Eclipse.
Operating Systems (e.g., Microsoft Windows, macOS, Linux).
Utility software (e.g., AVG Antivirus, Disk Cleanup, File Compression software, Backup utilities).
Programming Languages and Classification
Definition: Computer programming languages are symbolic instruction sets used by developers to create software, applications, operating systems, and web services.
Three Primary Generations/Types of Programming Languages:
1. Machine Language (Lowest-Level):
Composed entirely of binary digits ( and ).
Symbol represents the absence of an electrical pulse; symbol represents the presence of an electrical pulse.
Directly understood and executed by the computer hardware without requiring translation.
Provides the fastest execution speed and optimal memory efficiency.
Highly complex for humans to read, write, or debug.
2. Assembly Language (Low-Level):
Replaces binary codes with human-readable alphanumeric symbols called mnemonic codes (e.g.,
MOV,ADD,SUB,START,LABEL).Mnemonic codes typically consist of up to letters.
Also referred to as Symbolic Programming Language.
Requires a specialized language translator called an assembler to convert mnemonics into binary machine code.
Easier to debug and modify than machine language, but requires extensive hardware knowledge.

3. High-Level Languages (HLL):
Designed using English words and mathematical symbols to simplify program creation.
Does not require hardware mnemonic knowledge.
Follows a one-to-many translation ratio: a single high-level statement generates multiple low-level machine instructions.
User-friendly, easy to learn, maintain, and port across platforms.
Common High-Level Languages and Applications:
C: System programming, embedded systems, kernel drivers.C++: Game engines, enterprise software, high-performance computing.Java: Android application development, cross-platform enterprise software.Python: Artificial Intelligence (), Machine Learning (), data science, scripting, automation.JavaScript: Web application development (frontend and backend).

System Software and Language Translators
Language Translator: System software that converts programs written in high-level or assembly languages (source code) into executable machine code (target language in binary s and s).
Primary Translator Types:
Compiler:
System software that scans and translates the entire high-level source program at once into binary object code.
Detects syntax errors (grammatical violations) and semantic errors.
Generates separate object files (
.oor.obj).Example: GCC compiler for
C/C++.Assembler:
System software that translates symbolic assembly language mnemonics into machine code instructions.
Interpreter:
System software that reads, translates, and executes high-level source code line-by-line (statement-by-statement).
Executes code directly without saving a separate machine object code file.
Advantages: Simplifies incremental testing and debugging during development.
Disadvantages: Slower program execution speed due to real-time line-by-line translation.
Examples: Python, JavaScript, Ruby interpreters.
Comparative Summary of Translators:
Compiler: Input = High-Level Language; Output = Machine/Object Code; Translation Unit = Whole program simultaneously.
Interpreter: Input = High-Level Language; Output = Direct instruction execution; Translation Unit = Line/statement by statement.
Assembler: Input = Assembly Language; Output = Machine Code; Translation Unit = Instruction by instruction.
Program Development Lifecycle and Problem-Solving Tools
Stages of Developing a C Program:
Algorithm: Defining logical step-by-step computational steps.
Flowchart: Creating a diagrammatic/graphical representation of algorithm logic.
Pseudocode: Formulating informal English-like algorithmic logic.
Program: Writing actual syntax-compliant source code in
C.

Algorithms:
A finite set of ordered, unambiguous step-by-step instructions to solve a defined computational problem.
Example 1: Find Average of Three Numbers:
Step 0: Start
Step 1: Input first number into variable
Step 2: Input second number into variable
Step 3: Input third number into variable
Step 4: Compute
Step 5: Compute
Step 6: Display
Step 7: End
Example 2: Find Maximum of Two Numbers:
Step 0: Start
Step 1: Input variable
Step 2: Input variable
Step 3: If then else
Step 4: Display
Step 5: End
Example 3: Sum of First Natural Numbers:
Step 0: Start
Step 1: Input
Step 2: Set
Step 3: Set
Step 4: Repeat while :
(a)
(b)
Step 5: Display
Step 6: End
Flowcharts:
Graphical representation of an algorithm using standard ANSI symbols connected by directional flow lines.
Standard Flowchart Symbols:
Oval (Terminator): Represents start or end of a flowchart.
Rectangle (Process): Represents calculation or data processing step.
Parallelogram (Input/Output): Represents reading input or displaying output.
Diamond (Decision): Represents conditional evaluation requiring a Yes/No or True/False branch.
Arrow (Flow Line): Displays execution flow direction (top-to-bottom, left-to-right).
Circle (On-page Connector): Connects flow lines on the same page.
Off-page Connector: Connects flow lines across different pages.

Pseudocode:
An informal, English-like description of program logic lacking strict syntax syntax constraints.
Common keywords:
BEGIN/END,READ/INPUT,DISPLAY/PRINT,IF-ELSE,WHILE/FOR.Example: Find Maximum of Two Numbers in Pseudocode:
text BEGIN INPUT A INPUT B IF A > B THEN Max <- A ELSE Max <- B END IF OUTPUT Max END
Comparison: Algorithm vs Flowchart vs Pseudocode:
Algorithm: Step-by-step textual solution; easy to modify; less time required.
Flowchart: Graphical diagram; very easy to understand; difficult to modify; more time required.
Pseudocode: Structured English-like text; very easy to modify; minimal execution setup time.
History and Overview of the C Language
Origins of C:
Developed in the early 1970s by Dennis Ritchie at Bell Laboratories (AT&T).
Created as an enhanced successor to the
Bprogramming language.Standardized by the American National Standards Institute (ANSI) in 1989 (known as ANSI C or C89), and subsequently by ISO.
Definition of Programming: Systematic development of instructions directing a computer to accept input, process data according to logic, and yield output.
Core Characteristics and Importance of C:
Foundational structured programming language.
Provides raw hardware access and manual memory management capability.
Delivers high performance and fast execution speed.
Influenced modern successor languages including
C++,Java,C#, andPython.
Basic Structure of a C Program
Standard Structural Sections of a C Source File:
Documentation Section: Program descriptions written inside comments (
/* multi-line */or// single-line).Preprocessor Directive Section: Header inclusions (
#include <stdio.h>) and macro declarations (#define).Global Declaration Section: Program-wide global variables and function prototypes.
main() Function: Standard entry point required for execution.
User-Defined Subroutines/Functions: Supplementary custom function code.
Basic C Program Example: ```c
include // Preprocessor directive
int main() // Entry point function { int a = 5, b = 3, sum; // Variable declaration sum = a + b; // Executable statement printf("%d", sum); // Output statement return 0; // Function return statement } ```
C Preprocessor Directives and Conditional Compilation
Preprocessor Functionality:
System program operating on source code prior to syntax compilation.
Replaces preprocessor commands with expanded text, strips code comments (replacing them with spaces), and collapses duplicate blank lines.
Preprocessor directives always begin with a
#symbol and do not end with a semicolon;.
Common Preprocessor Directives:
#include: Inclusions of external standard or user header files (e.g.,#include <stdio.h>,#include <math.h>).#define: Defines symbolic constants or functional macros (e.g.,#define PI 3.14159).#undef: Undefines an existing symbolic macro.#if,#ifdef,#ifndef,#else,#elif,#endif: Directives controlling conditional code compilation.
Conditional Compilation Code Examples:
Example 1: Testing
#ifdef:
#include <stdio.h> #define DEBUG int main() { #ifdef DEBUG printf("Debug mode is ON"); #endif return 0; } ``` - *Example 2: Testing `#if` and `#else`*:c
include
define AGE 15
int main() {
if AGE >= 18
printf("Adult");else
printf("Minor");endif
return 0;} ```
Example 3: Multi-branch conditional
#elif: ```c
include
define MARKS 75
int main() {
if MARKS >= 90
printf("Grade A+");elif MARKS >= 75
printf("Grade A");elif MARKS >= 60
printf("Grade B");else
printf("Grade C");endif
return 0;} ```
Detailed C Compilation, Linking, Loading, and Execution Pipeline
The Six-Stage Compilation Pipeline (Acronym: P-C-A-L-L):
Preprocessing:
Input: Source code file (
program.c).Processing: Handles
#directives, expands macros, includes header code, strips comments.Output: Expanded source code file.
Compilation:
Input: Expanded source code.
Processing: Analyzes syntax/semantics, generates intermediate assembly.
Output: Assembly language file (
.sfile).
Assembly:
Input: Assembly language file (
.s).Processing: Translates mnemonics into relocatable binary machine code.
Output: Object file (
.oor.objfile).
Linking:
Input: Object files (
.o/.obj) + Standard library binary files.Processing: Links multi-file objects, resolves external symbol references (e.g., location of
printf()), assigns relative target memory addresses.Output: Binary Executable file (
.exe).
Loading:
Input: Executable file (
.exe).Processing: System OS loader copies executable binary from secondary disk into physical primary RAM memory.
Output: Program resident in physical RAM.
Execution:
Input: Program instructions in memory.
Processing: Central Processing Unit fetches, decodes, and executes binary instructions sequentially.
Output: Displayed screen output / computed results.

Detailed Role of the Linker:
Combines multiple compiled object files into a unified executable file.
Binds compiled binary subroutines from standard C library files (e.g.,
stdio.hbinary implementation).Resolves unresolved external function references across separate code modules.
Assigns absolute memory addresses to variables and functions.

Program Invocation vs Execution:
Invocation: The process of initiating or calling a program or function (e.g., issuing
hello();).Execution: The operational performance of CPU instructions inside the called routine.
Function Call Control Flow:
Program main starts execution.
Function call invocation
hello();pausesmain()control flow.CPU control jumps to
hello()function definition.Statements inside
hello()execute.Function returns control back to the instruction following the call site in
main().


C Tokens, Identifiers, and Keywords
Definition of C Token: The basic, smallest individual lexical unit of a C program.
Six Classifications of C Tokens:
Identifiers
Keywords
Constants
Strings
Special Symbols
Operators

Identifiers:
User-defined symbolic names designated for variables, custom functions, arrays, and structures.
Rules for Valid Identifier Names:
May contain letters (
A-Z,a-z), numbers (0-9), and underscores (_).Must start strictly with a letter or an underscore
_(cannot begin with a digit).Cannot use reserved C keywords.
Cannot contain whitespace or special symbols (e.g.,
$,#,@).Case-sensitive:
total,Total, andTOTALrepresent three distinct identifiers.Maximum standard identifier length is up to characters.
Examples:
Valid:
_marks,total1,avg_salary.Invalid:
1total(starts with digit),int(reserved keyword),avg salary(contains space),total#(illegal character).
Keywords:
Exactly reserved words in C possessing fixed predefined meanings. All keywords must be written in lowercase.
32 Keywords Categorization:
Type-related Keywords (16):
int,short,void,enum,float,long,struct,const,char,signed,union,volatile,double,unsigned,typedef,sizeof.Storage-related Keywords (4):
auto,static,register,extern.Control flow-related Keywords (12):
if,default,goto,for,else,case,continue,while,switch,break,return,do.
Character Sets, Strings, and Escape Sequences
String Tokens: Sequences of characters enclosed within double quotes (e.g., `