Chapter 1 Introduction to Programming PDF
Document Details
![LogicalAlbuquerque9838](https://quizgecko.com/images/avatars/avatar-2.webp)
Uploaded by LogicalAlbuquerque9838
Technological University of the Philippines
Patrick Justin L. Ariado
Tags
Summary
This document is Chapter 1 of a Computer Programming course from the Technological University of the Philippines. It provides an introduction to programming concepts, such as programming languages, and the software development lifecycle.
Full Transcript
TECHNOLOGICAL UNIVERSITY OF THE PHILIPPINES TAGUIG CAMPUS ITCC111-T - Computer Programming 1 CHAPTER 1 Prepared by: Patrick Justin L. Ariado Topics 01 0...
TECHNOLOGICAL UNIVERSITY OF THE PHILIPPINES TAGUIG CAMPUS ITCC111-T - Computer Programming 1 CHAPTER 1 Prepared by: Patrick Justin L. Ariado Topics 01 02 Computer Development Programming and Programming Lifecycle Language 03 04 Modeling Programming Tools Tools BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 2 01 Computer Programming and Programming Language Computer Programming The process of creating instructions or code that a computer can understand and execute. It involves writing a series of commands, functions, and algorithms to perform specific tasks or solve problems commonly known as Programs/Software. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 4 Programming Language A programming language is a structured computer language crafted for communicating instructions to a machine, with a particular emphasis on computers. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 5 Programming Language These languages allow programmers to instruct computers to perform specific tasks and generate computer programs that govern the actions of a machine. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 6 Source Code Source Code also known as code refers to the human-readable code that programmers write to instruct a computer on how to perform a specific task or function. It is a set of instructions, statements, and commands written in a specific programming language. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 7 Machine Language BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 8 Assembly Language BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 9 High-Level Language Before programs written in high-level languages can be executed, they need to undergo a translation process to a format comprehensible by the CPU. This translation is typically carried out through two main methods: compilation and interpretation. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 10 Compilation High-Level Language A compiler is a program that translates code into a standalone executable directly understood by the CPU. Once the code is compiled, the compiler isn't needed for program execution. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 11 Compilation High-Level Language BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 12 Interpretation High-Level Language An interpreter executes code directly without compiling it into machine code first. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 13 Interpretation High-Level Language BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 14 02 Development Lifecycle Development Lifecycle 1. Defining and Analyzing the Problem 2. Planning and Designing the Solution 3. Coding the Solution 4. Testing and Debugging the Solution 5. Implementing 6. Maintenance and Documentation BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 16 1. Defining and Analyzing the Problem Development Lifecycle This stage sets the foundation for the entire development process. A thorough understanding of the problem ensures that the program addresses the actual needs of users. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 17 2. Planning and Designing the Solution Development Lifecycle This stage involves strategic planning and the creation of a robust design that guides the software development process. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 18 2. Planning and Designing the Solution Development Lifecycle Algorithms play a crucial role in designing the logical flow and functionality of the software. They represent step-by-step instructions for solving specific problems or executing tasks efficiently. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 19 3. Coding the Solution Development Lifecycle This is where the theoretical design is translated into functional code. Developers follow coding standards and best practices to ensure maintainability. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 20 3. Coding the Solution Development Lifecycle Translate the designed algorithms into executable code using an appropriate programming language. Ensure that the coding adheres to established algorithmic principles and follows best practices. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 21 4. Testing and Debugging the Solution Development Lifecycle Conduct rigorous testing of individual algorithms to verify their correctness and efficiency. Use debugging tools to identify and rectify issues related to algorithmic logic. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 22 5. Implementing Development Lifecycle Implement the software, considering factors such as server configurations and infrastructure needed for efficient algorithm execution. Monitor the real-world performance of algorithms in the deployed environment. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 23 6. Maintenance and Documentation Development Lifecycle Ongoing maintenance ensures that the program remains functional, secure, and up-to-date. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 24 03 Modeling Tools Algorithm Algorithm Modeling Tools An algorithm is a well-defined, step-by- step procedure or set of instructions designed to perform a specific task or solve a particular problem. It is a fundamental concept in computer science and programming and serves as the basis for writing code. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 27 Algorithm Modeling Tools 1. It involves input, accepting one or more inputs to initiate its operations. 2. The algorithm engages in processing, subjecting the inputs to a structured sequence of well-defined steps. 3. The algorithm yields one or more outputs, presenting a solution to a given problem. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 28 Algorithm Modeling Tools BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 29 Algorithm Example Modeling Tools BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 30 Algorithm Example Modeling Tools Various methods exist for presenting algorithms to convey concepts and the necessary steps for problem-solving. Two widely utilized modeling tools for representing algorithms are pseudocode and flowcharts. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 31 Pseudocode Pseudocode Modeling Tools Pseudocode is a high-level, human- readable description of an algorithm, providing a means to articulate the logic of a program before the actual coding phase. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 33 Pseudocode Example Modeling Tools BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 34 Flowchart Flowchart Modeling Tools A flowchart is a visual representation of a process, system, or algorithm, employing standardized symbols and lines to illustrate the sequence of operations, steps, and decision points within it. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 36 Program Flowchart Modeling Tools In the context of flowcharts that represent algorithms otherwise known as program flowchart, a detailed visual representation is a powerful tool for explaining the step-by-step logic of the algorithm. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 37 Program Flowchart Modeling Tools The step-by-step progression of tasks, the branching of decisions, and the convergence of paths are all clearly presented in a flowchart. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 38 Programming Operators Programming Operators Programming operators are symbols that represent computations or actions performed on variables or values in a programming language. They enable developers to manipulate data, make comparisons, and control the flow of a program. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 40 Variables Programming Operators In programming, a variable is a symbolic name or identifier associated with a memory location that stores data. It serves as a container for holding information or values that can be manipulated and referenced within a program. The concept of variables is fundamental to programming languages and allows developers to work with and manage data dynamically. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 41 Programming Operators There are four main types of operators: 1. Arithmetic Operators 2. Relational/Conditional Operators 3. Logical Operators 4. Assignment Operators BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 42 1. Arithmetic Operators Programming Operators These operators perform basic mathematical operations on numeric values. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 43 1. Arithmetic Operators Programming Operators BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 44 Boolean Values Boolean values are a fundamental type of value in programming that represent the concept of truth or falsehood. Named after the mathematician and logician George Boole, boolean values can only have two possible states: True or False. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 45 2. Relational/Conditional Operators Programming Operators Relational operators compare two values and return a Boolean result (True or False). BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 46 2. Relational/Conditional Operators Programming Operators BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 47 3. Logical Operators Programming Operators Logical operators perform operations on boolean values and return boolean results. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 48 3. Logical Operators Programming Operators BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 49 4. Assignment Operators Programming Operators Assignment operators assign values to variables. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 50 Flowcharting Symbols Terminal (Oval) Program Flowchart Used to indicate the starting as well as the ending point of a flowchart. Labels that can be used are; START and STOP BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 52 Process (Rectangle) Program Flowchart Used to represent arithmetic operation or when casing individual variable assignments. Can contain only 1 calculation/process BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 53 Input/Output (Parallelogram) Program Flowchart Indicates input and output operations. Shows the flow of data and the device where such data is passing through during the processing. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 54 Decision (Diamond) Program Flowchart Used to evaluate a conditional statement and branch out to the required process depending on the outcome of the test which could either be true or false. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 55 Decision (Diamond) Program Flowchart Only three out of the four corners of the symbol are used for connective processing. Can contain only 1 conditional/logical statement The branches of the symbol is labeled YES or NO / TRUE or FALSE BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 56 Preparation (Hexagon) Program Flowchart Used to define a set of variables. Normally a process box is used for this, but sometimes due to the limitations associated with the process symbol, its use is critically inappropriate. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 57 On-page Connector (Small Circle) Program Flowchart Used to show a jump from one point to another within the same page BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 58 Off-page Connector (Pentagon) Program Flowchart Used to show flowcharting jump from one page to the next. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 59 Flowline (Arrow) Program Flowchart Used to show the directional flow of the process in the flowchart. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 60 Symbols Program Flowchart BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 61 General Flowcharting Guidelines Program Flowchart Flowchart can have only one start and one stop symbol On-page connectors are referenced using numbers Off-page connectors are referenced using alphabets General flow of processes is top to bottom or left to right Arrows should not cross each other BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 62 04 Programming Tools Programming Tools Before you start coding, you need to make sure that you and your machine is equipped for writing codes. Different Tools are needed to make your codes run. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 64 Executing Codes Executing Codes The following are the basic tools that are needed in order to write and run codes. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 66 Code Editor Designed for writing and editing source code. These editors are distinguished from text editors since there is an aim to either simplify or enhance the process of writing and editing of code for developers. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 67 Compiler/Interpreter Compilers transform source code that is written in a human readable/writable language in a form that computers can execute. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 68 Debugger Debuggers are used during testing and can help developers debug their application programs. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 69 Build automation tools These can help automate developer tasks that are more common to save time. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 70 Integrated Development Environment IDE BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 71 Integrated Development Environment (IDE) Are applications that facilitates the development of other applications. Designed to encompass all programming tasks in one application, one of the main benefits of an IDE is that they offer a central interface with all the tools a developer needs BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 72 Integrated Development Environment (IDE) Enables programmers to consolidate the different aspects of writing a computer program. IDEs increase programmer productivity by combining common activities of writing software into a single application: editing source code, building executables, and debugging. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 73 Integrated Development Environment (IDE) Common Features of an IDE Editing Source Code Syntax Highlighting Building Executables Debugging IntelliSense BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 74 IntelliSense Integrated Development Environment (IDE) code completion parameter info quick info member lists BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 75 History of IDE History of IDE Prior to IDEs, programmers wrote their programs in text editors. This involved writing and saving an application in the text editor before running “run” in the compiler, taking note of any error messages, and then going back to the text editor to revise their code. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 77 History of IDE It wasn’t until 1983 that Borland Ltd. acquired a Pascal compiler and published it as TurboPascal, featuring an integrated editor and compiler for the very first time. TurboPascal may have launched the idea of an integrated development environment, but many believe Microsoft’s Visual Basic (VB). BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 78 History of IDE Microsoft’s Visual Basic (VB) was launched in 1991, it was actually the first real IDE in history. Built in the older BASIC language, Visual Basic was a popular programming language through the 1980s. The rise of Visual Basic meant that programming could instead be thought of in graphical terms, and noteworthy productivity benefits became apparent. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 79 Types of IDE Types of IDE IDE’s can be categorized into 2 types: 1. Multi-Language IDE 2. Language-Specific IDE BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 81 Visual Studio Code Types of IDE: Multi-Language IDE Supports C++, C#, CSS, HTML, Java, JavaScript, JSON, PHP, PowerShell, Python, TypeScript, etc. Mainly considered as a text-editor only but with the use of extensions it can have IDE features. Several programming languages can be used after installation, like, JavaScript, TypeScript, CSS, and HTML but more rich language extensions can be found in the VS Code Marketplace. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 82 Eclipse Types of IDE: Multi-Language IDE Supports C, C++, Perl, Python, Ruby, PHP, Java and others. It is a free and open source editor for many development frameworks. Although it began as a Java development environment, it has expanded through plugins. This IDE is managed and directed by the Eclipse.org Consortium. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 83 NetBeans Types of IDE: Multi-Language IDE Supports Java, PHP, JavaScript, C, C++, Python, Ruby, and more. It is also free and open source. Modules provide all functions of the IDE. Developers can add support for other programming languages by installing additional modules. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 84 IntelliJ IDEA Types of IDE: Language-Specific IDE A powerful IDE for Java development but supports various other languages with plugins. Offers features like code completion, debugging, and testing for Java, Kotlin, Groovy, Scala, and more. Provides a rich set of tools for web development, databases, and frameworks like Spring. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 85 IntelliJ IDEA Types of IDE: Language-Specific IDE A powerful IDE for Java development but supports various other languages with plugins. Offers features like code completion, debugging, and testing for Java, Kotlin, Groovy, Scala, and more. Provides a rich set of tools for web development, databases, and frameworks like Spring. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 86 PyCharm Types of IDE: Language-Specific IDE Specialized for Python development but supports other languages like JavaScript, HTML, CSS, and more. Offers features like intelligent code completion, code inspection, and integrated testing for Python. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 87 Android Studio Types of IDE: Language-Specific IDE Mainly Supports Android programming through Java, but later version supports other languages like Kotlin and more with the use of extensions. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 88 Adobe Dreamweaver Types of IDE: Language-Specific IDE Mainly Supports HTML Development with a drag- and-drop capability in terms of layouting web applications. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 89 Visual Studio Types of IDE: Language-Specific IDE Mainly Supports Microsoft supported languages. Visual Studio is Microsoft's IDE, designed to create apps for the Microsoft platform. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 90 XCode Types of IDE: Language-Specific IDE Supports Swift and Objective-C languages, as well as Cocoa and Cocoa Touch APIs. This IDE is solely for creating iOS and Mac applications. It includes a GUI builder and an iPhone/iPad simulator. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 91 TASK SHEET 1 Evaluate the following logical expression. BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 92 TASK SHEET 1 1. !(4 > 6 || 2 == 2) 2. (!8 3) 3. (1 != 1 || 7 < 4) 4. (6 == 6 && !4 >= 5) 5. ((10 < 8 || 2 != 2) && 8!=6) BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 93 TASK SHEET 1 6. !(3 + 2 == 5 && 6 > 4) 7. (9 >= 7 || 3 < 1) 8. (!5 == 5 && !2 < 1) 9. !((2 * 4) != 8 || 6 < 5) 10.(3 = (5+2)) BASD | Bachelor of Technical-Vocational Teacher Education | ITCC111-T | Computer Programming 1 94