CCS 1400: Introduction to Programming and Flowcharting
Course Objectives
- Define Programming: Establish a foundational understanding of the programming process.
- Familiarize with Programming Universals: Understand the core elements shared across various programming languages.
- Identify Flowchart Symbols: Recognize the standard graphical representations used in process mapping.
- Create a Flowchart: Apply logic to design a visual representation of a program or process.
The Task of Programming
- Programming Definition: The process of preparing an instructional program for a device, such as a computer.
- Program Definition: A specific set of instructions that assists a computer in performing various tasks.
- Learning Requirements: Mastering a computer programming language involves learning two critical components:
- Vocabulary: The specific set of words or commands used by the language.
- Syntax: The specific rules of any given language that govern how commands are written and structured.
- Types of Programming Errors:
- Syntax errors: Violations of the language's rule set (e.g., typos, missing punctuation).
- Run-time errors: Errors that occur while the program is executing (e.g., dividing by zero).
- Logical errors: Flaws in the program's logic that lead to incorrect results even if the code runs without crashing.
Programming Universals and Language Classifications
- Programming Language: A tool used to write a program or a set of instructions for a computer.
- Primary Classifications:
- Machine Level Language:
- The lowest level of programming language.
- Directly handles binary data (0s and 1s).
- Interacts directly with the system hardware.
- Characteristics: Not portable and not readable by humans.
- Assembly Level Language:
- A low-level language that consists of specific instruction formats called commands.
- Uses symbols to represent fields of instructions.
- Operates very close to machine level language.
- Requires an Assembler to translate the assembly level program into machine level (binary) code.
- Characteristics: In human-readable format; takes less time to write and debug than machine code.
- Comparison Example:
- Assembly Language:
SUB AX, BX | Machine Code: 0010101110000011 - Assembly Language:
MOV CX, AX | Machine Code: 100010111001000 - Assembly Language:
MOV DX, 0 | Machine Code: 10111010000000000000000
- High-level Language:
- Uses a format or syntax that is most familiar to human users.
- Instructions in this language are specifically referred to as codes or scripts.
- Requires a Compiler or Interpreter to convert the code into machine level language.
- Examples: C++, Python, Java.
- Characteristics: Easy to write, less time-consuming, and highly readable.
- Code Example:
c
if (age < 18) {
printf("You are not eligible to vote");
} else {
printf("You are eligible to vote");
}
- Interpreter: A program that translates programming language instructions sequentially, one line at a time.
- Compiler: A program that translates the entire program into machine code all at once before execution.
- Running a Program: The act of issuing a command to execute the program statements written in the code.
- Testing a Program: Using sample data to determine if the program produces the correct results.
Logic and Control Structures
- Control Structures: The logic components within a program that determine the flow of execution.
- Sequence Structure: Steps are executed one after another in a linear fashion without interruption.
- Selection Structure: Used to perform different tasks based on whether a specific condition is met (often referred to as decision making).
- Loop Structure: Repeatedly performs a set of actions as long as a specified condition remains unchanged.
Procedural Programming
- Concepts:
- Programs consist of a series of steps or procedures that take place consecutively.
- Based on the concept of "calling procedures."
- Procedures: Also referred to as routines, subroutines, or functions. These consist of a series of computational steps to be executed.
- Functionality: During program execution, any specific procedure can be called by other procedures or even by itself.
- Language Examples:
- COBOL
- BASIC
- ALGOL
- FORTRAN
- Pascal
- C
- Code Implementation Example (C Language):
c
#include <stdio.h>
// Function to calculate area of a circle
double calculate_area(double radius) {
double area = 3.14159 * radius * radius;
return area;
}
int main() {
double radius = 7.0;
double area = calculate_area(radius);
printf("The area of the circle with radius %.2f is %.2f\n", radius, area);
return 0;
}
- Logic calculation: Area = 3.14159×radius×radius.
- Sample Output: "The area of the circle with radius 7.00 is 153.94"
Software Development Methodology
- Software Development Overview: The process of creating, testing, and maintaining software products and services to meet user needs.
- Development Methodologies: Frameworks or models that guide the process, outlining activities, deliverables, and the roles and responsibilities of the team members.
- Phases of the Software Development Life Cycle (SDLC):
- Project planning
- Gathering requirements and analysis
- Design
- Coding or implementation
- Testing
- Deployment
- Maintenance
- Common SDLC Models:
- Waterfall Model: A linear, sequential approach through requirements, design, implementation, testing, deployment, and maintenance.
- Agile Methodology: An iterative approach focusing on brainstorming, design, development, testing, and deployment with constant feedback loops and demos.
- Spiral Model: A risk-driven model involving objective identification, evaluations, risk management, development, and planning for the next phase.
Flowcharting: Symbols and Representation
- Definition: A flowchart is a graphical representation of the sequence of steps in a process.
- Standard Flowchart Symbols:
- Start/End (Oval): Used at the beginning and the end of the algorithm to signify the program's bounds.
- Arrows: Show the relationship and flow direction between different shapes.
- Input/Output (Parallelogram): Used for denoting program data entry (Input) and data display (Output).
- Process (Rectangle): Indicates internal processes such as mathematical operations or data assignments.
- Decision (Diamond): Represents decision points where an answer is typically "Yes" or "No." Lines representing different branches emerge from different points of the diamond.
- On-page Connector (Small Circle): Connects different parts of a flowchart that reside on the same page, usually marked with a letter to show matching points.
- Off-page Connector (Pentagon-like Shape): Connects parts of a flowchart that are spread across different pages.
Flowchart Logic Examples
- Sum of Two Integers Algorithm:
- Enter a number
- Enter another number
- Get the sum of the two numbers
- Print the sum
- Sum Flowchart Structure:
- Start -> Read A -> Read B -> Sum = A+B -> Print Sum -> End
- Average Calculation Flowchart:
- Start -> Take num1, num2 -> Average = 2num1+num2 -> Print Average -> End
Integrated Development Environment (IDE)
- IDE Definition: A coding tool that assists in automating editing, compiling, testing, and other SDLC steps.
- Purpose: Simplifies the process of writing, executing, and debugging code. It includes multiple tools used for the creation and testing of software.
- Popular Python IDEs:
- Wing
- Atom
- Eric
- PyDev
- PyCharm
- Spyder
- Microsoft Visual Studio
- Jupyter Notebook
- Thonny
- Rodeo