Download bài thi môn programing cuối kì and more Study Guides, Projects, Research Law in PDF only on Docsity!
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date 15/10/2023 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Chu Viet Chien Student ID BH Class (^) SEO6302 Assessor name (^) Ha Ngoc Linh Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P1 P2 M1 D
❒ Summative Feedback: ❒ Resubmission Feedback:
Grade: Assessor Signature: Date:
Table of figure
- I. Introduction ………………………….…………………………………………………………………………………….………….………… Table of contents
- II. Content ……………………………………………………………………………………………………………………………………………..
- Alogarithm: ..…………………………………………………………………………………………………………………………………..
- a,Definition………………………………………..……………………………………………………………………………………………..
- b,Features of alorithm……………………………..………………………………..……………………………………………………..
- c,Example…………………………………………………………………..………………………………………………………………….....
- 2.How to develop a program:.. …………………………………………………………………………………………………………..
- a, Defining or Analyzing the problem…………………………………………………………………………………………………
- b,Design (Algorithm)………………………………………………………………………………………………………………………….
- c,Coding…………………………………………………………………………………………………………………………………………….
- d,Documenting the program……………………………………………………………………….…………………………………….
- e,Compiling and running the program……………………………………………………………………………………………….
- f,Testing…………………………………………………………………………………………………………………………………………...
- g,Debugging………………………………………………………………………………………………………………….…………………..
- h,Maintenance……………………………………………………………………………………………………….………………………...
- 3.steps taken from writing code to execution : ………………...……………………………………………………………..
- 4.language programming: ………………………………………………………………………………………………………………...
- a, Analysis……………………………………………………………………………………………………………………………………...
- b, Evaluation…………………………………………………………………………………………………………………………………..
- c, Programming tool (IDE, Editor)…………………………………………………………………………………………………….
- 5 .Solve a problem with algorithm: ……..……………………………………………………………………………………………… - a,Question………………………………………………………………………………………………………………………………………. - b,Analyze problems………………………………………………………………………………………………….…………………….. - c,Flowchart…..………………………………………………………………………………………………………………………………… - d, Pseudocode………………………………………………………………………………………………………………………………… - e,code……………………………………………………………………………………………………………………………………………..
- III. Conclusion.. ……………………………………………………………………………………………………………………………….….
- IV. Reference List …….………………………………………………………………………………………………………………….…….
Figure 2: program development life Cycle. Figure 3: Tasks in defining a problem. Figure 4: Structure Charts. Figure 5: Flowcharts. Figure 6: Microsoft Visual Studios. Figure 7: Zend Studio. Figure 8: Zend Studio.
Contents
I. Introduction.
- Programming can be understood as a person who uses programming languages, code or utilities available to create a computer software, game, website, application,... This helps users simplify executing commands with laptops, or easily interact with each other through electronic devices. And people who do programming are collectively called programmers. Many people may think that programming is not as dry and boring as people think, but it is a miniature world that you can freely explore.
- You imagine a programmer as a rural person who is constantly caring, spending a lot of effort, sweat and time to create results? In the process of creating results, there can be many difficulties and challenges, but it is also impossible to spend time, health and effort. But with information technology in general and programming in particular, it is even more necessary. Why is that? Simply because this is not an easy profession, the pressure is very high if you do not have a right perspective, love and passion, it will be difficult to follow this profession.
II. Content.
1. Alogarithm:
a, Definition.
- Algorithm can simply be understood as a set of steps used to complete a specific task. They are the building blocks for programming and enabling things like computers, smartphones, and websites to function and make decisions. Algorithm can also be a procedure used to solve a problem or perform a
- Clear and Unambiguous : The algorithm should be unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning. - Well-Defined Inputs : If an algorithm says to take inputs, it should be well-defined inputs. It may or may not take input. - Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it should be well-defined as well. It should produce at least 1 output. - Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time. - Feasible: The algorithm must be simple, generic, and practical, such that it can be executed with the available resources. It must not contain some future technology or anything. - Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain - instructions that can be implemented in any language, and yet the output will be the same, as expected. - Input : An algorithm has zero or more inputs. Each that contains a fundamental operator must accept zero or more inputs. - Output : An algorithm produces at least one output. Every instruction that contains a fundamental operator must accept zero or more inputs. - Definiteness: All instructions in an algorithm must be unambiguous, precise, and easy to interpret. By referring to any of the instructions in an algorithm one can clearly understand what is to be done. Every fundamental operator in instruction must be defined without any ambiguity. - Finiteness: An algorithm must terminate after a finite number of steps in all test cases. Every instruction which contains a fundamental operator must be terminated within a finite amount of time. Infinite loops or recursive functions without base conditions do not possess finiteness. - Effectiveness: An algorithm must be developed by using very basic, simple, and feasible operations so that one can trace it out by using just paper and pencil.
c,Example. Find Roots of a Quadratic Equation ax^2 + bx + c = 0.
- Step 1: Start
- Step 2: Declare variables a, b, c, D, x1, x2, rp and ip;
- Step 3: Calculate discriminant D ← b2-4ac
- Step 4: If D ≥ 0 r1 ← (-b+√D)/2a r2 ← (-b-√D)/2a Display r1 and r2 as roots. Else Calculate real part and imaginary part rp ← -b/2a ip ← √(-D)/2a Display rp+j(ip) and rp-j(ip) as roots
- Step 5: Stop
2.How to develop a program:
- program development process consists of many different steps that are followed by a certain rule in order to be able to develop a computer program. Program development is similar to Software Development Life Cycle (SDLC), but is applied at a higher level to manage the development of multiple programs or software projects. In order to have the effectiveness of the programs used by various institutes or institutions, they should be developed regularly. Only then will the programs run most efficiently. Often IT companies use a circular approach to develop software solutions.. The method or procedure is as follows : The various steps involved are
- Defining or Analyzing the problem
- Design (Algorithm)
- Coding
Figure 3: Tasks in defining a problem. b, Design (Algorithm).
- Program design can be understood as the path from a problem to a solution in code, or starts by focusing on the main goal that the program is trying to achieve.when the program is well designed is capable of: easier to read and understand later - Fewer errors and errors, easier to extend to add new features, easier to program from the start. In this way, we can divide the program into manageable parts, each of which contributes to the goal. This program design approach is called upper-bottom program design or modular programming. Modular programming or modular design: the problem is clearly defined, several design methods can be applied, it is an important approach is Top-Down program design. It is a structured design technique , it divides the problem into a set of sub-problems called Modules and it creates a hierarchical structure of modules. For each module, the programmer will draw up a concept plan using the appropriate program designer to visualize how the module will perform the assigned work. Program Designer Tools: The various program design tools are described below:
- Structure Charts – A structure chart , also called Hierarchy chart , show top-down design of program. Each box in the structure chart indicates a task that program must accomplish. The Top module, called the Main module or Control module. For example: Figure 4: Structure Charts.
- Algorithms – An algorithm is a step-by-step description of how to arrive at a solution in the most easiest way. Algorithms are not restricted to computer world only. In fact, we use them in everyday life.
- Flowcharts – A flowchart is a diagram that shows the logic of the program. For example:
Figure 5: Flowcharts.
- Decision tables – A Decision table is a special kind of table, which is divided into four parts by a pair of horizontal and vertical lines.
- Pseudocode – A pseudocode is another tool to describe the way to arrive at a solution. They are different from algorithm by the fact that they are expressed in program language like constructs. c, Coding.
- Coding is an algorithm expressed in a programming language called a program. Program coding can be understood as translating an algorithm into a specific programming language. Programming techniques that use only well-defined control structures are called Structured Programming. The programmer must follow the rules of the language, violation of any rule causes errors. These errors must be eliminated before moving on to the next step.
- The programmer when encoding the program in various program languages into source code and compiling the program into object code for the machine. C++, JAVA, LIPS, ORACLE, FORTRAN, etc. are different languages they use to write program code. d, Documenting the program.
- Program documentation is explanatory documents: How the program works and how to use the program according to the user manual, how to maintain the program according to the developer's manual, and the details of specific programs, or specific parts of the program, easily forgotten or
debugging process to find and resolve bugs or defects that prevent the correct functioning of the program. h, Maintenance.
- Program maintenance is all activities that take place after the completion of the program. It is the process of maintenance and modification , to keep pace with changing requirements and technology. Moreover, program protection is not directly part of the implementation process but it plays an important role. Some of the program maintenance functions include:
- Finding and correcting the errors.
- Modify the program to enhance it. Besides, we must revise it regularly to adapt to some new government laws or policies. We must also modify it in case if we want to change the hardware or operating system.
- Update the documentation part.
- Add new features and functions.
- Remove useless parts of code.
- Despite the general perception that maintenance is required to correct bugs that arise after the software goes live, in practice, most maintenance work involves the addition of minor or key capabilities to existing modules. 3.steps taken from writing code to execution : B1: Define imput and output program requirements. B2:Define the algorithm. B3: Concretize and declare wings turn into sequences of commands. The pharmaceutical process is called drafting the source program.. B4 :Translate the source program to find and repair errors called syntax errors. B5: Run the program, check the output on the screen (check for algorithm errors).
- Example solving an equation of degree 1: ax + b = 0 B1: Define imput and output program requirements. -Imput : a , b (Number to enter ) -Output : x (Value to look for )
- First declare variables a,b. Next, enter the number a,b. B2:Define the algorithm.(ax+b=0) B3: Concretize and declare wings turn into sequences of commands. The pharmaceutical process is called drafting the source program. a==0) Folse, then the equation switches to b (a==0) True, then the equation has 1 unique solution (x=-b/a) (b==0) Folse, the equation has an infinite number of points (b==0) True, then the equation is insoluble
Syntax - The syntax can be understood as a rule for writing programs, each programming language will have its own writing syntax. Programmers need to distinguish syntax for different types of programming languages. Semantics - Semantics help determine the operations that the machine must perform. Through character combinations with certain combination rules, the machine will understand the context of that statement.
- Types of programming languages :
- A low-level programming language is the programming language that most closely resembles a machine language (0s and 1s), the functions of which are performed based on a set of instructions processed by the CPU. The "low-level" here is not that it is inferior to a high-level programming language, but because its instructions are close to machine language Therefore, programs written in low-level programming languages do not need compilers or interpreters. Therefore, the running speed of programs written in low-level programming languages is usually faster than high-level programming languages. +, Machine language Machine language is also known as machine language or machine code. Machine language is easier to read because it is usually displayed in binary (0s and 1s) or hexadecimal (base 16). It does not require a translator to convert programs because computers can directly understand programs written in machine language. Pros: Machine languages help programmers execute programs faster than high-level programming languages. +, Assembly language Assembly language (abbreviated as ASM) is also a type of programming language but is more complex than machine language or is considered an intermediate between high-level and low-level languages. It consists of a set of instructions that are symbolic and human-understandable, but still have to use assembler translators to convert assembly language into machine language. The conversion requires the programmer to have knowledge of both machine architecture and register structure. Pros: Assembly language requires less memory and takes less real time to execute programs.
- High-level Programming Language (HLL) is a language used to develop user-friendly software and websites that closely resemble human language. Therefore, it takes a compiler to convert to machine language for the computer to understand and execute the program. Pros: A high-level programming language is a programming language close to everyday language that makes it easy for users to read, write, and maintain. High-level programming languages include Python, Java, JavaScript, PHP, C#, C++, Objective C, Cobol, Perl, Pascal, LISP, FORTRAN, and Swift. +, Procedural programming language Procedure Oriented Programming (POP) is a structured and procedural programming technique. It divides a program into functions and in them can contain smaller subfunctions.
The procedural programming language POP is often used to create programs using a programming editor such as the IDE, Adobe Dreamweaver or Microsoft Visual Studio. Pros: POP makes it easy for programmers to track program flow and reusable code in other parts of the program. +, Object-oriented programming languages Object-oriented programming (OOP) based on objects. For OOP, the parts within it revolve around classes and objects with certain principles, have inheritance, acquire features of objects, and polymorphism creates many forms of functions. It is used to abstract objects in the real world. The program written in an object-oriented programming language is reusable, highly efficient, and easy to use. Pros: The object-oriented programming language is easy to implement, faster to handle, and easy to debug, modify and maintain. +, Natural language Natural programming languages are almost identical to languages used in everyday human communication like world languages such as French or Japanese. Through interpreters, machines can understand natural language and perform operations based on commands from natural language. Specifically, applications in named object recognition (NER), relationship extraction, and topic segmentation. Pros: Natural programming languages help users ask machines questions on any topic and get live answers within seconds.
- Intermediate programming languages
- A mid-level programming language is an intermediary between a low-level programming language and a high-level programming language. - Pros: Support for high-level, user-friendly and closely related programming language features as a stepping stone between machine language and human language. b, Evaluation
- Language evaluation criteria in programming languages are sets of standards and principles used to assess the quality and effectiveness of programming languages. These criteria are used to evaluate the features, design, syntax, and semantics of programming languages in order to determine their suitability for various applications and contexts. Programming languages are essential tools for developers in
for larger projects, where code can quickly become complex and difficult to understand. By using powerful abstractions, developers can reduce the amount of code required to achieve a particular result, making the code more maintainable and easier to understand. +,One of the key benefits of a language with good writability is that it allows developers to write code more efficiently and effectively. A concise syntax reduces the amount of code required to achieve a particular result, making the code easier to read and maintain. Similarly, easy-to- remember keywords and constructs make it easier for developers to write code without having to constantly refer to documentation or other resources.
3. Reliability
- Reliability refers to the ability of a language to produce consistent and predictable results, even in the presence of errors and unforeseen circumstances. A language with good reliability is less likely to produce unexpected results or crashes, making it more suitable for building robust and reliable software. +, A reliable language should also have a robust type system. A type system helps to prevent errors by ensuring that variables are of the correct type and that operations are performed only on variables of compatible types. This can help to catch errors early in the development process, reducing the likelihood of bugs and improving the reliability of the code. +, Another important aspect of reliability is the stability of the language itself. A reliable language should have a stable and consistent API, with minimal changes between versions. This helps to ensure that code written in one version of the language will continue to work in future versions, reducing the likelihood of compatibility issues and making it easier to maintain code over time. 4. Cost
- The cost of a programming language is indeed a function of various characteristics. As outlined in the statement, the following are the major factors that impact the cost of programming languages:
- Cost of training programmers: The cost of training programmers to use a language depends on the language’s simplicity and orthogonality. If a language is easy to learn and use, it can reduce the time and cost of training. Additionally, the experience of programmers also plays a role in the cost of training.
- Cost of writing programs: The writability of a language plays a critical role in the cost of writing programs. If a language is designed to be close in purpose to the particular application, it can reduce the time and cost of writing programs.
- Cost of compiling programs: The cost of compiling programs in a language depends on the quality of the compilers. Languages with high-quality compilers can reduce the cost of compiling programs.
- Cost of executing programs: The design of a language influences the cost of executing programs. If a language requires many run-time type checks, it can slow down the execution of programs, regardless of the quality of the compiler.
- Cost of language implementation system: The cost of implementing a language can impact its adoption. If free compiler/interpreter systems become available soon after a language’s design is released, it can reduce the cost of implementing the language.
- Cost of poor reliability: The cost of poor reliability can be very high, particularly in critical systems such as nuclear power plants or medical equipment. The cost of poor reliability can result in lost future business or lawsuits over defective software systems.
- Cost of maintaining programs: The cost of maintaining programs depends on the language’s readability. If a language is readable and easy to understand, it can reduce the cost of maintaining programs. c, Programming tool (IDE, Editor) 1.Visual Studio
- TheVisual StudioIDE is a Microsoft-powered integrated development interface developed to help software developers with web developments. The IDE uses artificial intelligence features to learn from the edit programmer’s make to their codes, making it easy for it to complete lines of code automatically. Figure 6: Microsoft Visual Studios.