Printable Notes - Programming Concepts (Exam Focus)
Introduction:
Programming is the method of designing and writing instructions (code) that a computer can execute
to perform specific tasks. It involves problem solving, logic building, and algorithmic thinking.
A Program:
A program is a set of instructions written using a programming language to perform a specific task. It
is the actual implementation of logic or algorithms.
Programming Languages:
These are formal languages used to write programs. Examples include C, C++, Python, Java.
Programming languages provide syntax and semantics for expressing instructions.
Role of Programming Language:
Programming languages act as a medium between human logic and machine execution. They help
translate algorithms into executable code using a compiler or interpreter.
Language Description:
Describes the syntax (structure) and semantics (meaning) of the programming language constructs.
It includes grammar rules, reserved words, and valid statements.
Elements of Program:
Basic elements include: Variables, Constants, Operators, Control Statements, Loops, Functions,
Data types.
Variable:
A variable is a named memory location used to store data during program execution. Its value can
change. Example: int age = 20;
Constant:
A constant is a fixed value that cannot be altered during program execution. Example: const float pi
= 3.14;
Compilation:
The process of converting source code into machine code using a compiler. It involves multiple
stages like lexical, syntax, semantic analysis.
Compiler:
A compiler is a software that translates the entire program into machine code before execution.
Assembler:
Translates assembly language programs into machine code.
Data Types:
Defines the type of data a variable can hold. Basic types: int, float, char, double, void.
Flowchart:
A graphical representation of an algorithm using symbols. Used to plan and visualize logic.
DFD (Data Flow Diagram):
DFD is used in system design to show the flow of data through processes, storage, and data
sources/destinations.
Algorithm:
A step-by-step method to solve a problem. It is independent of programming language.
Sequence Control:
Executes instructions one after another in the written order without branching or looping.
Subprogram Control:
Uses functions or procedures to modularize code. Helps in reusability and clarity.
Condition Checking:
Used in decision making using statements like if, if-else, switch.
Loops:
Used for repeating code blocks. Types: for, while, do-while.
Functions:
A function is a block of code that performs a specific task and can be called multiple times.
Arrays:
Arrays are collections of elements of the same data type. 1D array: int arr[5]; 2D array: int mat[2][2];
Basic Algorithms:
Examples: Sum of N, Factorial, Prime check, Fibonacci.
Pointers:
A pointer is a variable that stores the address of another variable. Syntax: int *p;
File Handling:
Operations used to read/write files: fopen(), fread(), fwrite(), fclose().
Imperative Programming:
Based on sequential statements and control flow. Example: C, Fortran.
Object-Oriented Programming:
Focuses on objects and classes. Features: Encapsulation, Inheritance, Polymorphism.
Functional Programming:
Emphasizes pure functions and avoids changing state. Example: Haskell, Lisp.
Logic Programming:
Uses rules and facts. Based on formal logic. Example: Prolog.
Concurrent Programming:
Multiple tasks executing simultaneously or overlapping in time. Used in multi-threaded or multi-core
systems.
Network Programming:
Programs that allow communication between computers using protocols like TCP/IP. Example: Web
apps, sockets.