- Programming involves writing instructions for a computer to perform tasks. Programming languages make this easier by using English-like commands rather than binary code.
- The program development life cycle involves analyzing the problem, designing a solution algorithm and flowchart, coding the solution in a programming language, testing for errors, and documenting the program.
- Key steps include problem analysis, program design using algorithms and pseudo-code, development by coding the design in a programming language, testing the program, and maintaining it after installation.
- Programming involves writing instructions for a computer to perform tasks. Programming languages make this easier by using English-like commands rather than binary code.
- The program development life cycle involves analyzing the problem, designing a solution algorithm and flowchart, coding the solution in a programming language, testing for errors, and documenting the program.
- Key steps include problem analysis, program design using algorithms and pseudo-code, development by coding the design in a programming language, testing the program, and maintaining it after installation.
COMPUTER PROGRAMMING – 1 consists of 0’s and 1’s which
INTRODUCTION makes programming very difficult.
Programming • Assembly Language – uses • Series of instructions to a ―abbreviation‖ or mnemonics in computer to accomplish a task. place of binary patterns in order • Instructions must be written in a to make task of programming way the computer can easier. understand • Assembler – is special program • Programming languages are used that translates assembly language to write programs instructions into a machine • Once the code (language) of language instruction. program has been written, it must be executed (run, started). Programming languages • Set of commands that a computer has been ―taught‖ to understand • Languages that look like ―machine code‖ (e.g 82A8; jsr r5, @#82AE 82AC: sob ro, 8296) are High level Language used for Uses English – like commands or • Writing games instructions, is the easiest to use and • Writing application contains many complicated or advance programs (like Excel) instructions, also known as the third Other languages look like English “high generation language. level, “e.g, PRINT “HELLO”) Compiler • Logo Is a special program that translates high • JavaScript – level languages instruction into a Examples of an instruction to print the machine language instruction. word “HI” Fourth Generation Language • Logo - PR [HI] A programming language designed with • JavaScript - alert(“HI”) a specific purpose in mind such as the • FORTRAN - PRINT “HI” development of commercial business • BASIC - PRINT “HI” software. • COBOL - DISPLAY “HI” • C++ - printf(“HI”); • Pascal - WRITELN(“HI”) • Assembly - XPRINT MESSAGE1
Types of programming languages
• Machine Language – is a natural or primitive language that the computer actually understand, PROGRAMMING FUNDAMENTAL - An algorithm is written, which is an - Computer is an electronic device English-like explanation of the solution. that accepts data, processes it, - A flowchart is drawn, which is a and generates the relevant diagrammatic representation of output. It can perform both simple the solution. The solution is represented and complex tasks with very high diagrammatically, for easy speed and accuracy. understanding and clarity. However, a computer cannot - A pseudo code is written for the selected solution. Pseudo code perform any task—simple or uses the structured complex, of its own programming constructs. The - Computers need to be instructed pseudo code becomes an input about ―how‖ the task is to be to the next phase. 3. Program Development performed. The set of instructions - The computer programming that instruct the computer about languages are of different kinds— the way the task is to be low-level languages, and high-level languages like C, performed is called a program. A C++ and Java. The pseudo code program is required for processing is coded using a all kind of tasks—simple tasks like suitable programming language. - The coded pseudo code or addition of two numbers, and program is compiled for any complex tasks like gaming etc. syntax errors. Syntax errors arise due to the incorrect use of programming language or PROGRAM DEVELOPMENT LIFE CYCLE due to the grammatical errors Three essential parts: with respect to the programming 1. Instructions to accept the input language used. During data that needs to be processed, compilation, the syntax errors, if any, are removed. 2. Instructions that will act upon the - The successfully compiled input data and process it, and program is now ready for 3. Instructions to provide the output execution. - The executed program generates to user. the output result, which may be A person who writes the program correct or incorrect. The program (computer programmer) has to follow is tested with various inputs, to see that it generates the desired the Program Development Life Cycle. results. If incorrect results are displayed, then the program has 1. Problem Analysis—The semantic error (logical programmer first understands the error). The semantic errors are problem to be solved. The removed from the program to get programmer determines the the correct results. various ways in which the problem - The successfully tested program is can be solved, and decides upon ready for use and is installed on a single solution which will be the user’s followed to solve the problem. machine. 2. Program Design—The selected 4. Program Documentation and solution is represented in a form, Maintenance—The program is so that it can be coded. properly documented, so that later on, anyone can use it This requires three steps: and understand its working. Any changes made to the program, after installation, forms part of the maintenance of Both the algorithms accomplish the program. The program same goal, but in different ways. The may require updating, fixing of programmer selects the algorithm errors etc. during the based on the advantages and maintenance phase. disadvantages of each algorithm. For example, the first algorithm has more SUMMARISES THE STEPS OF THE PROGRAM number of comparisons, whereas in DEVELOPMENT CYCLE the second algorithm an additional variable MAX is required.
Example2: Write an algorithm that
reads two values, determines the largest value and prints the largest value with an identifying message.
ALGORITHM
- Algorithm is an ordered sequence CONTROL STRUCTURES
of finite, well defined, unambiguous instructions for o specify the statements to completing a task. Algorithm is an be executed and the order English-like representation of the of execution of statements. logic which is used to solve o There are three kinds the problem. of control structures: - It is a step-by-step procedure for a) Sequential—instructions solving a task or a problem. The are executed in linear steps must be order ordered, unambiguous and finite b) Selection (branch or in number. conditional)—it asks a true/false question and Example1: Algorithm to find the greatest then selects the next among three numbers. instruction based on the answer Algorithm 1 c) Iterative (loop)—it Step 1: Start repeats the execution Step 2: Read the three numbers of a block of instructions A, B, C Step 3: Compare A and B. If A is FLOWCHART greater perform step 4 else perform step 5. o A diagrammatic Step 4: Compare A and C. If A is representation of the logic greater, output “A is greatest” else for solving a task. A output “C is greatest”. flowchart is Perform step 6. drawn using boxes of Step 5: Compare B and C. If B is different shapes with lines greater, output “B is greatest” else connecting them to show output “C is greatest”. the flow of control Step 6: Stop Preparing a Flowchart
o A flowchart may be simple
or complex. The most common symbols that are used to draw a flowchart are—Process, Decision, Example4: Find the profit/loss Data, Terminator, when income = 1000 and cost = Connector and Flow lines. 800 o While drawing a flowchart, some rules need to be followed. A flowchart should have a start and end.
PSEUDO CODE
o Pseudo code consists of
short, readable and formally-styled English language used for explaining an algorithm. o Pseudo code does not include details like variable declarations, subroutines etc. o Pseudo code is a short- hand way of describing a computer program. Example3: Find the sum of 529 and 256