←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Revision

Programming Methodology · Unit 1 Revision

Quick summary and key points for Unit 1

Program Concept, Stages in Program Development & Methodologies

Overview: For a fee calculator, first decide how concessions affect the total.

What is a Program?

  • Think of a computer like a super-fast worker who has zero common sense.
  • Program: A set of coded instructions written in a programming language (like C, C++, or Java) that tells the computer what to do and…
  • Programming: The process of writing, testing, fixing (debugging), and maintaining these instructions.
  • Programmer: The person who writes this code to solve a real-world problem.

Key Characteristics of a Good Program

  • Writing code that just runs is not enough.
  • 1. Correctness & Accuracy It must give 100% correct output for all valid inputs and handle edge cases properly.
  • 2. Efficiency (Speed & RAM) It should run fast (low CPU usage) and take as little memory (RAM) as possible.
  • 3. Readability & Clean Code Uses meaningful variable names, proper indentation, and comments so anyone can understand it easily.
  • 4. Robustness (No Crashing) Handles wrong user inputs (like typing text when a number is expected) without crashing suddenly.
  • Portability: The program should run on different operating systems (like Windows, Linux, and macOS) with little or no change.
  • Modularity: The code is broken down into small, independent parts (functions or classes) so it is easy to test, fix, and reuse.

View diagram · Key Qualities of a Good Program

Stages in Program Development Life Cycle

  • Before writing code directly in Turbo C++ or VS Code, professional programmers follow a clear 6-stage process:
  • Stage 2 Algorithm & Flowchart
  • Stage 3 Coding / Writing Code
  • Stage 4 Compiling & Debugging
  • Stage 5 Testing & Verification
  • Stage 6 Documentation & Maintenance
  • Easy Explanation of All 6 Stages: Problem Definition & Analysis:
  • Algorithm & Flowchart Design:

View diagram · The 6 Stages of Program Development

Types of Programming Methodologies

  • Over time, programmers have used different approaches (paradigms) to build software:
  • A. Procedural / Structured Programming (POP): Main Idea: Focuses on functions and procedures (doing actions step by step).
  • Data Security: Data moves freely from function to function using global variables.
  • Approach: Follows a Top-Down approach (starts with the big problem and breaks it down into smaller functions).
  • Examples: C, Pascal, FORTRAN.
  • B. Object-Oriented Programming (OOP): Main Idea: Focuses on data and objects rather than just functions.
  • Data Security: High security!
  • Approach: Follows a Bottom-Up approach (creates small building blocks like classes first, then combines them into a full project).

Comparison: Procedural Programming (POP) vs. Object-Oriented Programming (OOP)

  • This is one of the most important questions in DAVV exams!
  • Main Focus: Focuses on functions and doing actions
  • Design Approach: Top-Down approach
  • Program Division: Program is divided into functions
  • Data Security: Less secure (data is shared globally)
  • Data Movement: Data moves freely between functions
  • Code Reusability: Low reusability

Algorithms, Flowcharts & Design Notations

Overview: To find the largest of three marks, start with the first as the largest and compare the other two in turn.

What is an Algorithm?

  • An Algorithm is simply a step-by-step list of instructions written in plain English to solve a specific problem.
  • This step-by-step recipe is an algorithm!
  • 5 Essential Properties of an Algorithm (Donald Knuth Criteria): For college exams, remember these 5 points:
  • Finiteness: The algorithm must stop after a fixed number of steps.

What is a Flowchart?

  • A Flowchart is a diagram or visual picture of an algorithm.
  • Standard ANSI Flowchart Symbols: The oval marks a start or end and the rectangle marks a processing step.
  • Oval / Rounded Box (Terminal) Used for the START or STOP / END of the program.
  • Parallelogram (Input / Output) Used for reading data from the user ( INPUT A ) or printing results ( PRINT Sum ).
  • Rectangle (Process) Used for calculations and assigning values to variables ( Sum = A + B ).
  • Diamond (Decision / Condition) Used for checking conditions ( Is A > B?
  • Arrows (Flowlines) Shows the direction in which the program moves (usually top-to-bottom or left-to-right).
  • Small Circle (Connector) Connects different parts of a big flowchart on the same page without crossing lines.

View diagram · Standard Flowchart Symbols & Their Purpose

Practical Algorithm & Flowchart Examples

  • Flowchart Logic Map: Compare the input values and follow the branch whose condition holds.
  • Start & Input Accept inputs A, B, and C
  • Check A > B Branch YES (test A vs C) or NO (test B vs C)
  • Compare with C Evaluate surviving candidate against C
  • Print Largest & Stop Output maximum value and terminate

View diagram · Decision Flowchart: Finding the Largest of Three Numbers

Advantages & Limitations of Flowcharts

  • Easy to Understand: Non-technical people and beginners can easily understand the program logic visually.:** Hard to Modify: If you want to change a small step, you often have to redraw the whole diagram from…
  • Easy Bug Finding: Helps you spot logic errors or missing conditions before typing any code.:** Takes Too Much Space: Flowcharts for large software take up several pages and become messy.
  • Language Independent: The same flowchart can be used to write code in C++, Java, or Python.:** Can Get Confusing: If there are too many branches and loops, lines cross each other and look like…

C++ History, Applications, Compiling & Linking Process

Overview: A compiler can accept a call when it sees a suitable function declaration.

A Brief History of C++

  • In 1979, a Danish computer scientist named Bjarne Stroustrup was working at AT&T Bell Laboratories in the USA.
  • Simula 67: Had wonderful concepts like classes, objects, and inheritance, but was too slow to run real system tasks.
  • C Language: Was super fast and close to hardware, but lacked modern tools (like classes) to manage large software projects easily.
  • Speed of C + Object-Oriented Features of Simula = C++!
  • 1979: ‘C with Classes’ The first version was created by adding classes and basic inheritance to the standard C language.
  • 1983: Renamed to C++ Rick Mascitti suggested the name C++ .
  • 1985: First Release First public version released along with Bjarne’s famous textbook: ‘The C++ Programming Language’ .
  • 1998 to Present Standardized by ISO (C++98), followed by modern versions like C++11, C++14, C++17, and C++20.

View diagram · Milestones in the Evolution of C++

Where is C++ Used in Real Life? (Applications)

  • Why do we still study C++ today?
  • Operating Systems: Major parts of Windows, macOS, and Linux are written in C and C++.
  • Video Games & Game Engines: Popular 3D games (like GTA, PUBG) and game engines like Unreal Engine use C++ to achieve 60 to 120+ frames per second…
  • Web Browsers: Google Chrome (V8 JavaScript engine) and Mozilla Firefox use C++ to render web pages instantly.
  • Databases: Fast databases like MySQL and MongoDB run their core engines in C++.
  • Stock Markets & Banking: High-Frequency Trading systems on Wall Street and Mumbai Stock Exchange process millions of transactions per second using…

Your First C++ Program Explained Line-by-Line

  • Line-by-Line Breakdown: #include <iostream>: The # symbol is a preprocessor directive.
  • using namespace std;: cout and cin live inside a namespace called std.
  • int main(): Every C++ program must have a main() function.
  • cout <<: Pronounced as “see-out”.
  • cin >>: Pronounced as “see-in”.
  • endl: Means “end line”.
  • return 0;: Returning 0 tells your operating system: “Program executed successfully without any errors!”

The 4-Stage Compiling & Linking Process

  • When you click “Run” in your compiler (like Dev-C++, Code::Blocks, or VS Code), your code passes through 4 automatic stages to become a runnable…
  • Expanded Code (.i) Headers added, comments removed
  • Object Code (.obj / .o) Machine code in binary
  • Executable (.exe) Ready to run program
  • What Happens in Each Stage: Preprocessing (Preprocessor):
  • Removes all comments (// and `/* …
  • Replaces macros (like #define MAX 100).
  • Copies the contents of header files (like <iostream>) directly into the file.

View diagram · C++ Build Pipeline

Tokens, Data Types & Reference Variables in C++

Overview: In int marks = 75, int is a keyword, marks is an identifier and 75 is an integer literal.

What are Tokens in C++?

  • Just like words and punctuation marks form an English sentence, tokens are the smallest individual building blocks of a C++ program.
  • 1. Keywords Reserved words with fixed meanings that you cannot change ( int , class , return , for ).
  • 2. Identifiers Names that you give to variables, functions, and classes ( rollNo , totalMarks , Student ).
  • 3. Constants (Literals) Fixed values that never change during program execution ( 10 , 3.14 , ‘A’ ).
  • 4. Strings A sequence of characters written inside double quotes ( “Hello Indore” , “CampusNotes” ).
  • 5. Operators Symbols that perform calculations or comparisons ( + , - , * , == , :: ).
  • 6. Punctuators / Delimiters Punctuation marks used to structure code ( ; , { , } , ( , ) , [ , ] ).

View diagram · The 6 Categories of C++ Tokens

Rules for Naming Identifiers (Variables)

  • When creating variable or function names, always follow these 5 basic rules:
  • Allowed Characters: You can use letters (a-z, A-Z), digits (0-9), and the underscore (_).
  • First Character: The name must start with a letter or an underscore.
  • Case-Sensitive: C++ treats uppercase and lowercase letters differently.
  • No Keywords: You cannot use reserved keywords as variable names (e.g., you cannot name a variable int, class, or while).
  • No Spaces or Special Symbols: Spaces and symbols like @, #, !, % are strictly not allowed.

Constants: Making Values Unchangeable

  • A Constant is a value that cannot be changed once defined.
  • Why is const better than #define?: Type Safety: const has a specific data type (int, float), so the compiler can check for errors.
  • Scope Control: const variables can be kept local inside a specific function or class.

Data Types in C++

  • Data types tell the compiler what kind of value a variable will hold and how much memory (RAM) it needs.
  • int: 4 Bytes (32-bit)
  • char: 1 Byte
  • float: 4 Bytes
  • double: 8 Bytes
  • bool: 1 Byte
  • void: 0 Bytes

View diagram · Classification of C++ Data Types

Reference Variables in C++ (The “Nickname” Concept)

  • A Reference Variable is one of the most useful features of C++.

Reference Variables vs. Pointers (Exam Comparison)

  • Students often get confused between a reference and a pointer.
  • Basic Meaning: An alias (another nickname) for an existing variable
  • Syntax: int &ref = a;
  • Initialization: Must be initialized immediately when created
  • Can it be NULL?: No! A reference can never be NULL
  • Can it point to another variable?: No! Once linked to a, it can never be changed
  • Dereference Symbol: No symbol needed; use directly like a normal variable

C++ Operators: Scope Resolution, ‘new’ & ‘delete’ Memory Management

Overview: If a local variable hides a global variable, the scope resolution operator can identify the global one.

Overview of Operators in C++

  • C++ has all the regular operators that you already learned in C language:
  • Arithmetic: +, -, *, /, %
  • Relational / Comparison: <, >, <=, >=, ==, !=
  • Logical: && (AND), || (OR), ! (NOT)
  • Assignment: =, +=, -=, *=
  • Scope Resolution Operator (::)
  • Dynamic Memory Operators (new and delete)

The Scope Resolution Operator (::)

  • Imagine you have two variables with the exact same name: one global (defined outside all functions) and one local (defined inside…
  • 1. Access Global Variables Accesses a global variable when a local variable has the same name ( ::count ).
  • 2. Define Functions Outside Class Tells C++ which class a member function belongs to ( void Student::display() ).
  • 3. Access Static Class Members Calls static variables or functions without creating an object ( Math::pi ).
  • 4. Namespace Resolution Tells the compiler which library namespace to use ( std::cout ).

View diagram · Four Key Roles of the Scope Resolution Operator (::)

Dynamic Memory Management: new and delete

  • Normally, when you create a variable like int a = 10;, memory is allocated on the Stack automatically.
  • new operator: Allocates memory from the heap while the program is running.
  • delete operator: Frees that memory so RAM is not wasted.
  • How to Use new and delete: Important Note: When deleting a single variable, use delete ptr;.
  • What are they?: Built-in C++ operators
  • Calls Constructor?: Yes! Automatically calls constructors and destructors
  • Type Safety: Returns the exact pointer type (e.g.
  • Size Calculation: Compiler automatically calculates size

C++ Manipulators (<iomanip>)

  • Manipulators are special formatting functions used with cout << to change how output looks on the screen (like setting columns or decimal…
  • Common Manipulators: endl: Moves the cursor to the next line (same as \n) and clears the output buffer.
  • setw(n): Sets the width of the output field to n spaces.
  • setprecision(n): Controls how many digits appear after the decimal point in floating-point numbers.
  • setfill(ch): Fills empty spaces with a custom character (like * or -).

Type Casting (Changing Data Types)

  • Type casting means converting a value from one data type to another (for example, converting a float with decimals into an int).

Conditional & Iterative Statements in C++: Loops & Switch-Case

Overview: An if chooses whether to process a mark.

What are Control Flow Statements?

  • Normally, a C++ program runs line-by-line from top to bottom.
  • 1. Selection (Decision-Making) Runs a specific block of code based on whether a condition is true or false ( if , if-else , switch ).
  • 2. Iteration (Loops) Repeats a block of code multiple times until a condition becomes false ( for , while , do-while ).
  • 3. Jump Statements Jumps directly to another part of the program ( break , continue , return ).

View diagram · Control Flow Categories in C++

Decision-Making Statements (Conditionals)

  • A. Simple if and if-else: Used when you have two choices:
  • B. The else-if Ladder (Multiple Choices): Used when you have many conditions to check in sequence:
  • C. The switch-case Statement: When you have a menu with multiple options (like a calculator), using many if-else blocks gets messy.
  • Why is break so important in switch?
  • If you forget to write break;, C++ doesn’t stop after the matching case!
  • Exam Tip: In C++, switch only works with integers (int) and characters (char).

Iterative Statements (Loops in C++)

  • Instead of writing cout << "Hello" << endl; 100 times, you can put it inside a loop!
  • Entry-Controlled (Pre-Test) Loops The condition is checked BEFORE entering the loop body.
  • Exit-Controlled (Post-Test) Loops The condition is checked AFTER the loop body runs.

View diagram · Loop Categorization by Condition Check Point

Comparison: while vs. do-while Loop

  • Look at this simple example to see the exact difference:
  • Where is condition checked?: At the entry (beginning) of the loop
  • Minimum number of executions: 0 times (if condition is false initially)
  • Trailing Semicolon: No semicolon at the end: while (cond) { }
  • Best Used For: General tasks where condition must be met first

Jump Statements: break vs. continue

  • Both break and continue are used inside loops to alter execution:
  • break; Stops the entire loop immediately and jumps out to the next statement outside the loop.
  • continue; Skips only the remaining lines of the current iteration and jumps directly to the next loop cycle.

View diagram · Loop Control Flow: Break vs Continue