Skip to main content
Back

Structured Programming: Concepts, Paradigms, and Data Structures

Study Guide - Smart Notes

Tailored notes based on your materials, expanded with key definitions, examples, and context.

Introduction to Structured Programming

Definition and Purpose

Structured programming is a systematic approach to software development that emphasizes clarity, modularity, and maintainability. It involves breaking down complex problems into smaller, manageable sub-problems and organizing code into logical structures.

  • Programming: The process of converting problem solutions into instructions for a computer.

  • Structured Programming: An approach that uses modular design and control structures to create readable and maintainable programs.

History of Programming Languages

Generations of Programming Languages

Programming languages have evolved through several generations, each offering increased abstraction and ease of use.

  • First-Generation (Machine Language): Direct binary instructions executed by the CPU. Difficult to debug and maintain.

  • Second-Generation (Assembly Language): Symbolic code translated to machine language. Easier than machine code but still hardware-specific.

  • Third-Generation (High-Level Languages): Human-readable languages (e.g., C, C++, Java) that are portable and easier to use.

  • Fourth-Generation Languages: High-level languages focused on database and business applications (e.g., SQL, SAS).

  • Fifth-Generation Languages: Languages designed for artificial intelligence and logic programming (e.g., Prolog).

Low-Level vs. High-Level Languages

  • Low-Level Languages: Closer to hardware, less portable, more difficult to use.

  • High-Level Languages: Closer to human language, easier to read and maintain, more portable.

Programming Paradigms

Main Paradigms

Programming paradigms define the style and structure of computer programs.

  • Unstructured Programming: Code executed in sequence, often using Goto statements. Difficult to maintain.

  • Structured Programming: Uses top-down design, modularity, and control structures (sequence, selection, iteration).

  • Object-Oriented Programming (OOP): Organizes code into objects with properties and methods.

  • Visual Programming: Uses graphical elements to design programs.

  • Internet-Based Programming: Focuses on web technologies and online applications.

Structure of a C Program

Components

  • Source Code Files: Original program instructions written by the programmer.

  • Object Code: Machine language code produced by a compiler.

  • Executable File: File format that can be directly executed by a computer.

  • Standard Library: Collection of precompiled functions for common tasks.

Basic Elements

  • Keywords: Reserved words in C (e.g., int, return).

  • Identifiers: Names for variables, functions, etc.

  • Comments: Non-executable statements for documentation.

  • Statements: Instructions such as assignments, function calls, and control flow.

Data Types and Variables

Definitions

  • Data Type: Specifies the type and size of data a variable can hold (e.g., int, float).

  • Variable: A named memory location for storing data.

  • Constant: A value that does not change during program execution.

Operators in C Programming

Types of Operators

  • Arithmetic Operators:

  • Assignment Operators:

  • Increment/Decrement Operators:

  • Relational Operators:

  • Logical Operators:

  • Conditional (Ternary) Operator:

Operator Precedence and Associativity

Operators have a defined order of evaluation, known as precedence, and rules for grouping, known as associativity.

Control Structures

Types and Importance

Control structures determine the flow of execution in a program.

  • Sequence: Executes statements in order.

  • Selection: Makes decisions (if, if-else, switch).

  • Iteration: Repeats statements (for, while, do-while).

Examples

  • If Statement:

  • For Loop:

  • While Loop:

Functions in C

User-Defined and Library Functions

  • User-Defined Functions: Created by the programmer to perform specific tasks.

  • Library Functions: Predefined functions provided by the C standard library.

Function Structure

  • Declaration: Specifies the function's name, return type, and parameters.

  • Definition: Contains the actual code to be executed.

  • Calling: Invokes the function from another part of the program.

Data Structures

Arrays

  • Declaration:

  • Initialization:

  • Accessing Elements:

Sorting Techniques

Sort Type

Description

Bubble Sort

Repeatedly swaps adjacent elements if they are in the wrong order.

Selection Sort

Selects the minimum/maximum element and places it at the correct position.

Shell Sort

Improves insertion sort by comparing elements separated by a gap.

Quick Sort

Divides the array into partitions and sorts recursively.

Other Data Structures

  • Linked Lists: Sequence of nodes where each node points to the next.

  • Pointers: Variables that store memory addresses.

  • Stacks: Last-in, first-out (LIFO) structure.

  • Queues: First-in, first-out (FIFO) structure.

  • C Strings: Arrays of characters ending with a null character.

File Handling

Operations

  • Opening Files:

  • Closing Files:

  • Writing to Files:

  • Reading from Files:

Software Documentation

Types

  • Process Documentation: Describes the development process.

  • Product Documentation: Details the software product and its usage.

Summary Table: Key Programming Concepts

Concept

Definition

Variable

Named memory location for storing data.

Constant

Value that does not change during execution.

Operator

Symbol that performs operations on operands.

Function

Reusable block of code performing a specific task.

Array

Collection of elements of the same type.

Pointer

Variable storing a memory address.

Stack

LIFO data structure.

Queue

FIFO data structure.

Additional info: These notes are expanded and organized for clarity and completeness, suitable for exam preparation in a college-level programming course.

Pearson Logo

Study Prep