COMPUTER-PROGRAMMING-REVIEWER.pdf
Document Details
Uploaded by SuccessfulRing
University of the Philippines Los Baños
Tags
Full Transcript
LESSON 1: UNDERSTANDING COMPUTER SYSTEMS COMPUTER SYSTEM - combination of all the components required to process and store data - composed of multiple pieces of hardware and software. (Farrell, 2015) MAJOR COMPONENTS OF COMPUTER SYSTEM: HARDWARE, SOFTWARE, AND HUMAN RESOURCES HARDWARE - equ...
LESSON 1: UNDERSTANDING COMPUTER SYSTEMS COMPUTER SYSTEM - combination of all the components required to process and store data - composed of multiple pieces of hardware and software. (Farrell, 2015) MAJOR COMPONENTS OF COMPUTER SYSTEM: HARDWARE, SOFTWARE, AND HUMAN RESOURCES HARDWARE - equipment, or the physical devices, associated with a computer. For example, keyboards, mice, speakers, and printers are all hardware. - computer hardware needs instructions that control how and when data items are input, how they are processed, and the form in which they are output or stored. SOFTWARE - is computer instructions that tell the hardware what to do. - Software is programs, which are instruction sets written by programmers. SOFTWARE CAN BE CLASSIFIED INTO TWO BROAD TYPES: APPLICATION SOFTWARE - a word-processing programs, spreadsheets, payroll and inventory programs, and games. In short it is the apps that you install in your computer. SYSTEM SOFTWARE - are programs that you use to manage your computer, including operating systems such as Windows, Linux, or UNIX for larger computers and Google Android and Apple iOS for smartphones. HARDWARE AND SOFTWARE ACCOMPLISH THREE MAJOR OPERATIONS INPUT - Data items enter the computer system. - Data items include all the text, numbers, and other raw material that are entered into and processed by a computer. - Hardware devices that perform input operations include keyboards and mice. - also include items such as images, sounds, and a user’s mouse or finger-swiping movements. PROCESSING - may involve organizing or sorting them, checking them for accuracy, or performing calculations with them. - Writing programs that efficiently use several CPUs requires special techniques. OUTPUT - Resulting information usually is sent to a printer, monitor, or some other output device so people can view, interpret, and use the results. - Programming professionals often use the term data for input items, but use the term information for data. - output on storage devices, such as your hard drive, flash media, or a cloud-based device. (The cloud refers to devices at remote locations accessed through the Internet.) PROGRAM CODE - The instructions you write using a programming language. CODING THE PROGRAM - when you write programming instructions. - Programming language has rules governing its word usage and punctuation. These rules are called the language’s SYNTAX. - Mistakes in a language’s usage are SYNTAX ERRORS. - Computer languages have translators that are commonly called compilers or interpreters - The program must be translated into machine language or binary language that represents million of on/off circuits within the computer. Program statements are called source program and the translated machine language statements is called object code. PEOPLEWARE OR HUMAN RESOURCES - Peopleware refers to the human role in an IT system. Here are some key points about peopleware: 1. Development Productivity: Peopleware addresses the productivity of developers and teams. It explores how individuals and groups can work efficiently to create high-quality software. 2. Teamwork and Group Dynamics: Understanding how teams collaborate, communicate, and function is crucial. Effective teamwork contributes to successful project outcomes. 3. Psychology of Programming: Peopleware delves into the psychological aspects of programming. It considers factors such as motivation, cognitive load, and decision-making. 4. Project Management: Managing projects involves coordinating people, resources, and timelines. Peopleware examines project management practices that lead to successful software development. 5. Organizational Factors: The organizational context significantly impacts software development. Peopleware considers organizational culture, learning, and adaptability. 6. Human Interface Design: Creating user-friendly interfaces requires an understanding of human behavior and cognitive processes. Peopleware emphasizes designing interfaces that align with users’ mental models. 7. Human–Machine Interaction: How humans interact with machines (software and hardware) affects usability and efficiency. Peopleware explores ways to optimize this interaction. INFORMATION PROCESSING CYCLE In a computer-oriented data processing system, there are four logical sequences that are being followed and done, they are: 1. Input 2. Process 3. Output 4. Storage INPUTS are provided by users and are needed by the computer hardware for it (hardware) to do something depending on what instruction is to be done. After data has been entered, they are stored in the memory where processing then takes place. PROCESSING is the manipulation of data based on the instruction given, either mathematically or logically such as organizing, sorting, calculations, etc. and are done by the Central Processing Unit or CPU. When processing is done, output or result can now be retrieved. Output, which is also considered as information are processed data, organized and made more meaningful and important to the person receiving it. STORAGE. Data storage in computers converts data to sequences of 0s and 1s. Memory is divided into bytes, each storing a letter or small number. For meaningful operations, computers require large amounts of bytes. Instructions are written in computer programming languages like Java, C/C++, C#, VB.Net, Go, Python, PHP, JavaScript. Programmers follow syntax rules, similar to human language usage. ELEMENTS OF COMPUTER PROGRAMS: Computer programs can be divided into; 1. SYSTEM PROGRAMS, 2. UTILITY PROGRAMS 3. APPLICATION PROGRAMS. SYSTEM PROGRAMS refer to all programs that require the computer to function effectively. It is the intermediary or the bridge that links computer users and the hardware. UTILITY PROGRAMS are programs provided so that user can maintain the computer system, APPLICATION programs written by user to obtain solution to a specific problem that transform a computer machine into a tool for performing a specific kind of work. COMPUTER PROGRAM IS COMPOSED OF DIFFERENT ELEMENTS, THEY ARE: 1. LANGUAGE; 2. DATA; 3. EXPRESSION/OPERATION; 4. STATEMENT OR COMMAND LANGUAGE - The process of program design and implementation is called programming. - programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. PROGRAMMING LANGUAGES ARE DIVIDED INTO THREE LEVELS: 1. High-level languages 2. Middle-level language - hybrid 3. Low-level languages. HIGH-LEVEL PROGRAMMING LANGUAGES (HLL) - PASCAL, BASIC, or C allows the programmers to express the program using keywords or reserved words and syntax that resemble to human natural language. - Each statement in a high-level language corresponds to several machine language instructions - runs more slowly than that of programs written in a lower level of programming language. HIGH-LEVEL LANGUAGE - These languages are close to natural language - the spoken and written language of humans, - C, C++, Java, Perl and COBOL - lets the developer focused on the logic of the problem to be solved. (Bitesize, 2020). LOW-LEVEL PROGRAMMING LANGUAGES (LLL) - requires more detailed expertise about exact capabilities of a given computer system and its microprocessor - Programming in a lower-level language requires more time. MACHINE LANGUAGE Numeric codes for direct computer operations. Codes consist of 0s and 1s, binary digits. Converted from and to hexadecimal for human viewing and modification. Instructions use bits for operations and operands. Difficult to read and write due to lack of resemblance to mathematical notation or human language. Codes vary from computer to computer. ASSEMBLY LANGUAGE Level 1 above machine language. Uses short mnemonic codes for instructions. Allows programmers to introduce names for memory blocks. Designed for easy translation into machine language. Doesn't provide sophisticated organization of complex information. Requires detailed knowledge of internal computer architecture. Useful for programming computers to interact with input/output devices. DATA Defined as formal representation of facts, concepts, or instructions for communication, interpretation, or processing. Represented using alphabets, digits, or special characters. Data is a collection of factual information in numbers, letters, or symbols. Data is necessary for computer function through the installed program. Data are like raw materials in production of goods. Input data is entered into the machine through input devices. Data is transformed into output data, commonly known as information. SPLASH- greetings program (printf, main, etc.) DATA ARE CATEGORIZED OR CLASSIFIED INTO TWO: 1. the numeric 2. the non-numeric. NUMERIC DATA - are used for mathematical computations. - Numeric data items can be an integer (whole number) or a real number (with a decimal or floating point or fractional part). NON-NUMERIC DATA - is composed of alphanumeric (letters or numerical figures) character or any special symbol, such as $, ! etc. - Non-numeric data are usually organized into sequences of characters enclosed in an open and close quotation mark ( “ or ‘ ) and are commonly called string. - Non-numeric or string data are used for giving description and identification - Not normally used for mathematical computation. DATA ARE USED OR REPRESENTED IN A PROGRAM AS 1. constant 2. variable. CONSTANT - data item that is commonly described as literal value. - This data item does not change during program execution. - Constant can be of numeric or string (non-numeric) in type. NUMERIC CONSTANT maybe an integer or a real numbers which may either be preceded by a positive (+) or a negative (-) sign. Example: INTEGERS 100 10 +25 -125 REAL 10.3526 0.125 -0.143 +13.425 Numeric constant may contain only of the following characters: 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,. , +, -. No other characters must appear or must be used together with the characters shown above. 15 EXAMPLE OF ILLEGAL CONSTANT WITH ILLEGAL CHARACTERS. 100,000 - comma is not allowed. $ 125.00 - $ symbol to signify monetary value is not allowed. 10 inches - inches as a description should not be used. 18 ¼ - slash (/) is a symbol of division and is not allowed. STRING CONSTANT - a group of characters enclosed in constant may include numerical form (numbers 0-9), letters from A-Z or a-z and all other characters like $, space, % and etc. EXAMPLE OF STRING CONSTANTS: “A” “ _”(space) “14344” “Gorio’s Store” “How are you” “200” VARIABLE - Variable is the names we give to computer memory locations which are used to store values in a computer program. - It is a named data item, the value of which may change during the execution of the program. - The values stored in a variable are not permanent. - During the program execution, variables reside in the memory of the computer. - Variables store data in numeric or string types. - Numeric variables hold values of numeric types. - String variables hold values of string or non-numeric types. - Variables should be declared at the beginning of the program or in specific areas. Variables should be given their own unique (no duplication) name. (Variable name are normally called identifier). EXAMPLE (no duplication) name. “autom” “automotive” “automatic” NAME OF VARIABLES ARE GIVEN BASED ON THE FOLLOWING RULES OR REQUIREMENTS: 1. must contain only letters, numbers and an underscore character ( _ ) 2. must always begin with a letter 3. must be unique (no duplication of names) 4. must not be a keyword or reserve word (keyword are word with a special meaning to the computer like commands or statements) 5. should not start with a number EXAMPLES: X GRP1 GRP2 STUDENT_ID Grand_total X3 Total A243B X2X EXPRESSION Involves combining variables, constants, operators, and functions in a single statement. Acts on specific programming language. Composed of operands separated by an operator. Operands can be data items (constant or variable). Operators express the operation to be done. Can be arithmetic, logical, relational, or string. A + 25 - 3 OPERATORS OPERANDS LTR= LEFT TO RIGHT MDAS= (MD) (AS) EXPRESSIONS ARE OF DIFFERENT TYPES, THEY ARE: 1. Arithmetic expression 2. String expression 3. Boolean expression ARITHMETIC EXPRESSION - called numeric expression - consisting numeric constant or numeric variable operands, separated by an arithmetic operator, which yield a numeric value. Arithmetic operators are the following: operators operation to be done + addition - subtraction * multiplication / real division (result is real number) div, / integer division (result is an integer number) mod, % modulus division (extract the remainder) ^ , ** exponentiation (in Basic) -- decrement ++ increment Div or / and mod or % - These operators use integer operands and yield an output value which is also an integer. - Div or % operator yields a truncated quotient (no floating point or decimal number) - while mod extract the remainder of a division operation. MIXED ARITHMETIC EXPRESSION - Mixed expression is an expression having several operands and operators. Parenthesis can be used to group a sequence or certain portion of an expression. Examples: 8+4–3 9 * ( 3 + 25 ) ( 5 ^ 2 + ( 35 – 30 ) % 3 ) mod 5 When dealing with mixed expressions, precedence rule or order of operation must be considered. Operators with the highest priority must be done first. - If you could notice *, /, % or div, and mod are of the same priority as well as – and +. In this case the rule of left-to- right sequence should be observed. Operator on the left side will be done first. - In any expression, operations inside parenthesis are done first. In the case that parenthesis encloses mixed operations, order of precedence is in effect. Nested parenthesis (a parenthesis inside another parenthesis) the innermost parenthesis is evaluated first ahead of the outer parenthesis. STRING EXPRESSION - is an expression consisting of string constant or string variable operands separated by a string operator which yield a string value. Format of String Expression - operand → operator → operand → operator → operand… String Operator (+) concatenation Concatenation is process or operation by which the value of the second operand (right operand) is appended or attached to the end of the first operand (left operand). (The + operator adds if operands are numeric type and will concatenate if operands are string type). Example of incorrect expressions - 13 + “25” first operand is numeric and the second is string - “Dog” + 20 first operand is a string and the second is numeric