Fundamentals of Programming PDF
Document Details
Uploaded by MesmerizedComplex
Prince Justin D. Acaylar
Tags
Summary
This document is about fundamentals of programming. It covers computer systems, hardware, software, types of software, and programming languages. Examples and explanations are included in the content.
Full Transcript
CCPRGG1L FUNDAMENTALS OF PROGRAMMING Prince Justin D. Acaylar | INF241 | PROF. Mrs. Lalaine P. Abad CHAPTER 1: Overview of 3 Major Operations Programming ✦ Computer hardware and Computer Systems...
CCPRGG1L FUNDAMENTALS OF PROGRAMMING Prince Justin D. Acaylar | INF241 | PROF. Mrs. Lalaine P. Abad CHAPTER 1: Overview of 3 Major Operations Programming ✦ Computer hardware and Computer Systems software accomplish three major operations in most programs ✦ Combination of all components required to process Input - Data items such as and store data using computer text, numbers, and other raw material that are entered into Hardware - equipment a processed by a computer associated with a computer Processing - Organizing or Software - computer sorting data, checking them instruction that tell the hardware for accuracy, or performing what to do calculations with then using the central processing unit Software (CPU) ✦ Programs - set of computer Output - The resulting instructions written by information after data programmers processing that is sent to a printer, a monitor, or some ✦ Programming - writing other output devices such as software instructions storage devices. The cloud refer to devices at remote ✦ Logic of a computer program locations accessed through - the complete sequence o tasks the internet. that lead to a problem’s solution Programming Language Types of Software ✦ Used to write computer ✦ Application software such as instructions called program code word-processing programs, spreadsheets, payroll and ✦ Writing instructions is called inventory programs, and games coding the program ✦ System software includes e.g. Visual Basic, C#, C++, or operating systems, which include Java Windows, Linux, or UNIX for larger computers and google ✦ Syntax - rules that govern the Android and Apple iOS for word usage and punctuation used smartphones in every programming language. ✦ Syntax errors - Mistakes in a Execution language’s usage ✦ When instructions are carried ✦ Computer Memory - out, a program executes, or runs Computer’s temporary, internal storage where program Some input will be accepted, instructions are stored some processing will occur, and results will be output Random Access Memory (RAM) - form of internal, volatile memory InternetOutput storage is volatile Cloud - its contents are lost when the computer is turned off or ✦ Cloud - Devices at remote loses power locations accessed through the Internet ✦ Permanent storage devices Nonvolatile memory After data items have been processed by a computer, the ✦ Compiler or interpreter output data is sometimes stored on a storage device. Translates source code The cloud refers to devices at into machine language remote locations accessed (binary language) statements through internet. The data called object code cannot be read or interpreted directly from these storage Checks for syntax errors devices, but the devices hold information for later retrieval. Compilers vs Interpreters Understanding Simple Compilers and Interpreters is the same - they translate Program Logic programming statements into ✦ Programs with syntax errors code the computer can use. cannot be translated fully and cannot be executed However, when you use a compiler, an entire program is ✦ Programs with no syntax errors translated before it can execute. might produce incorrect output due to logical errors But when you use an interpreter, each instruction is translated Errors in program logic that just prior to execution. produce incorrect output Usually, programmers do not choose which type of translation to use - it depends on the programming language ✦ The number-doubling process 2. Planning the Logic includes three instructions: ✦ The heart of the programming The instruction to input process myNumber is an example of an input operation ✦ Programmer plans the steps of the program, decides what The instruction myAnswer = steps to include and how to order myNumber*2 is an example them of a processing operation ✦ Most common planning tools The output myAnswer Flowcharts instruction is an example of an Pseudocode output operation ✦ Algorithm - the sequence of Program Development Cycle steps or rules to be followed to solve a problem ✦ Desk-checking - walking through a program’s logic on paper before the program is actually written Thinking about all the possible data values a program might encounter How the programmer wants the program to handle each scenario 1. Understanding the Problem ✦ Users or end users - people 3. Coding the Program for whom a program is written ✦ Hundreds of programming Programmers must first languages are available understand what the user want Chosen based on features Similar in their basic Documentation - all capabilities supporting paperwork for a program that is provided to ✦ Some experienced help programmers understand programmers can successfully the problem combine logic planning and program coding in one step ✦ One of the most difficult aspect of programming ✦ Coding is easier than the planning step 4. Using Software to ✦ After a program is free of syntax errors, the programmer Translate the Program into can test it Machine Language Programmer can execute the program with some samples ✦ Translator program written by a data to se whether the results compiler or interpreter: are logically correct Changes the programmer’s English-like high-level ✦ Debugging - the process of programming language into finding and correcting program low-level machine language errors (low-level programming A program is debugged by language) Output testing is using many sets of data ✦ Syntax error - translator program issues an error message 6. Putting the Program into if a programming statement is written incorrectly Production ✦ Process depends on the Programmer corrects the program’s purpose received list of syntax errors May take several months *Might need to recompile the code several times ✦ Conversion - entire set of actions an organization must take to switch over to using a new program or set of programs 7. Maintaining the Program ✦ Maintenance - making necessary changes after the program is put into production ✦ Common first programming job for programmers Figure: Creating an Executable Program 5. Testing the Program Maintaining previously written ✦ Logical Error - results when a programs syntactically correct statement, but the wrong one for the current ✦ Programmer makes changes to context, is used existing programs Repeats the development cycle Using Pseudocode ✦ Each program statement perform one action — for Statements and Flowcharts example, input, processing, or Symbols output ✦ Pseudocode - English-like ✦ Whenever a module name is representation of the logical steps used, it is followed by a set of it takes to solve a problem parentheses ✦ Flowchart - pictorial ✦ Modules begin with the module representation of the logical steps name and end with return; these are always aligned Writing Pseudocode Drawing Flowcharts ✦ Pseudocode representation of a number-doubling problem ✦ Process - draw geometric shapes that contain the individual statements and that are start connected with arrows input myNumber myAnswer = myNumber*2 ✦ Input symbol - Indicates an output myAnswer input operation stop Parallelogram Pseudocode Standards ✦ Programs begin with start and end with stop; these two words Figure: Input Symbol are always aligned ✦ Program statements are ✦ Processing symbol - Contains indented a few spaces processing statements such as arithmetic operation statements ✦ Each program statement appears on a single line if Rectangle possible If this is not possible, continuation lines are Figure: Processing Symbol indented ✦ Program statements begin with lowercase letters ✦ No punctuation is used to end a statement ✦ Output symbol - Contains Repeating Instructions output statements ✦To avoid high consumption of Parallelogram time while writing a program: Often called the input/output Create a loop - repetition of a symbol or I/O symbol as it is series of steps used for both input and output Avoid an infinite loop - repeating flow of logic with no end Using a Sentinel Value to Figure: Output Symbol End a Program ✦ Decision symbol - represents ✦ Flowlines - Arrows that testing a value or evaluating an connect steps to show the correct expression in a flowchart sequence of statements Diamond shape - contains a ✦ Terminal symbol or start/stop question or evaluation, the symbol answer to which is one of two mutually exclusive options Placed at each end of a flowchart ✦ Dummy value - preselected value that stops the execution of Shaped like a racetrack a program Does not represent real data, Also referred to as a lozenge but just a signal to stop Figure 1-6: Flowchart and Referred to as sentinel value eof (‘end of file) - marker that Pseudocode for Program the end of a file that that Doubles a Number automatically acts as sentinel Understanding Programming and User Environments ✦ To enter a word processing program into a computer, a keyboard is usually to type program statements into an editor Plain text editor Text editor that is part of an integrated development environment - program used to create simple text files Integrated Development Environment ✦ Software package that provides an editor, compiler, and other programming tools. e.g: Microsoft Visual Studio IDE ✦ Features It uses different colors to display various language components, making elements like data types easier to identify It highlights syntax error visually It employs automatic statement completion It provides tools that allow one ✦ Command Line - a location on to step through a program’s your computer screen at which execution one statement at a you type text entries to time communicate with the computer’s operating system A C# Number-Doubling ✦ Graphical User Interface Program in Notepad (GUI) - allows users to interact with a program in a graphical environment Function of a Text Editor ✦ A text editor is a program that can be used to create simple text files. ✦ It is similar to a word processor but without as many features. ✦ Notepad is a text editor that is included with Microsoft Windows. ✦ An advantage to using a simple text editor to type and save a program is that the completed program does not require much disk space for storage. Executing a Number-Doubling Example: Object-oriented programmers might design Program in a Command-Line a payroll application by Environment thinking about employees and paychecks and by describing their attributes Understanding the Evolution of Programming Models ✦ Major models or paradigms used by programmers Procedural programming - Focuses on the procedures that programmers create Focuses on the actions that are carried out Example: Getting input data for an employee and writing the calculations needed to produce a paycheck from the data Object-oriented programming (OOP)- Focuses on objects, or “things,” and describes their features (also called attributes) and their behaviors