Download assignment by vietnam and more Assignments Information Technology in PDF only on Docsity!
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 0: Procedural Programming
Submission date Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Nguyen Tan Khoi Student ID GCD
Class Pro101 Assessor name Ly Quynh Tran
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 (^) khoi
Grading grid
P1 P2 P3 M1 M2 D
Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date:
Lecturer Signature:
- Chapter 1: Problem Statement....................................................................................................................................
- 1.1 SCENARIO...............................................................................................................................................................
- 1.2 REPORT OBJECTIVES..............................................................................................................................................
- 1.3 OVERVIEW OF THE REPORT...................................................................................................................................
- Chapter 2: PRINCIPLES OF PROCEDURAL PROGRAMMING......................................................................................
- INTRODUCTION....................................................................................................................................................
- THE SPECIAL THINGS IN COMPUTER AND PROGRAM..........................................................................................
- Chapter 3: INTRODUCTION TO PROCEDURAL PROGRAMMING.........................................................................
- Simple program..............................................................................................................................................
- Variable..........................................................................................................................................................
- Contructions...................................................................................................................................................
- Function.........................................................................................................................................................
- Value passing (parameter).............................................................................................................................
- Parameter passing (Pointer)..........................................................................................................................
- Modularity.....................................................................................................................................................
- Chapter 4: DESIGN PROCEDURAL PROGRAMMING SOLUTIONS........................................................................
- Identify Input, Output....................................................................................................................................
- The required construction for the Management solution..............................................................................
- Hierachical diagram of the program..............................................................................................................
- Use-case diagram...........................................................................................................................................
- Flow Chart Diagrams......................................................................................................................................
- Chapter 5: REFERENCES.....................................................................................................................................
- Chapter 6: INDEX OF COMMENT.......................................................................................................................
- Figure 1.3-1: People and technology..........................................................................................................................
- Figure 1.3-2: Computer................................................................................................................................................
- Figure 1.3-3: Computer program.................................................................................................................................
- Figure 1.3-4: Program Development Process.............................................................................................................
- Figure 1.3-5: Flowchart of ”Hello world”...................................................................................................................
- Figure 1.3-6: Code simple program............................................................................................................................
- Figure 1.3-7: Result of simple program......................................................................................................................
- Figure 1.3-8: Global and variables.............................................................................................................................
- Figure 1.3-9: Sequence construct..............................................................................................................................
- Figure 1.3-10: Example..............................................................................................................................................
- Figure 1.3-11: If statement........................................................................................................................................
- Figure 1.3-12: code if statement................................................................................................................................
- Figure 1.3-13: Switch case statement........................................................................................................................
- Figure 1.3-14: Code switch-case................................................................................................................................
- Figure 1.3-15: Iteration Structure..............................................................................................................................
- Figure 1.3-16: For loop example................................................................................................................................
- Figure 1.3-17: While loop statement.........................................................................................................................
- Figure 1.3-18: Do while loop statement....................................................................................................................
- Figure 1.3-19: Function declaration syntax................................................................................................................
- Figure 1.3-20: Library function and user-defined function........................................................................................
- Figure 1.3-21: Code of Passing Parameter.................................................................................................................
- Figure 1.3-22: Main variables in function..................................................................................................................
- Figure 1.3-23: Choice menu function.........................................................................................................................
- Figure 1.3-24: input ID Function................................................................................................................................
- Figure 1.3-25: Input local variable function...............................................................................................................
Figure 1.3-26: Choice Menu Function........................................................................................................................ 22 Figure 1.3-27: Enter List student Function................................. 22 Figure 1.3-28: Display student.................................................... 22 Figure 1.3-29: Display student detail.......................................... 23 Figure 1.3-30: Find highest......................................................... 24 Figure 1.3-31: Find lowest.......................................................... 25 Figure 1.3-32: Switch-case Statement in math........................... 26 Figure 1.3-33: if statement in math............................................ 27 Figure 1.3-34: For Statement..................................................... 27 Figure 1.3-35: Do-while loop...................................................... 28 Figure 1.3-36: Hierachical diagram of the program.................... 28 Figure 1.3-37: Use-case diagram................................................ 29 Figure 1.3-38: Flow Chart Diagrams........................................... 30
ACKNOWLEGEMENT
First of all, I would like admit the responsible persons from
University of Greenwich who provide this coursework for
students. I would like to thank to all the authors and
researchers who researched about DEV C++ program.
Moreover, I would like to present my appreciation for our
lecturer, they support me at the first, always Enthusiastic
answers to my questions , for her great and expert lectures
and guidelines. Last but not least, I would like to appreciate
responsible teachers and staffs from our centre, I’m very
proud of for providing such a good learning environment.
Signature of Student(Electronic signature)
Analysis and Design a solution for procedural programming problem
Assignment 1
Chapter 1: Problem Statement
1.1 SCENARIO
Here is the solutions to solve this problem:
Identify the variables and data types required in the program.
Identify and describe 2 different selection structures, including the condition(s) to check; state
why they are needed and where they can be used in the context of the scenario.
Identify and describe any iteration constructs.
Split the program into functions (sub-functions) and draw a hierarchy diagram to illustrate the
structure of your program.
1.2 REPORT OBJECTIVES
Understand the principles of procedural programming Display and design procedural programming keys Can be clear more about programmer job Improvement ability write code for person begin
1.3 OVERVIEW OF THE REPORT
Chapter 1: Problem statement Chapter 2: Principles of procedural programming Chapter 3: Analysis and design procedural programming solution Chapter 4: Design procedural programming solutions References Index of comment A math teacher wants to manage grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, student’s grades and store these information into 2 separate arrays (integer array for IDs and float array for grades). Then he needs to print all student IDs together with their grades. Finally, he needs to know which student has highest grade and lowest grade. Your program should be menu based with the options above. When an option is done, the program should go back to the main menu so he can choose another option. There should be an option to quit program.
Chapter 2: PRINCIPLES OF PROCEDURAL PROGRAMMING
- INTRODUCTION In the past, the most of us had a lot of hard problem that it solved by conventional methods. It took to a long time or sometimes it almost can not to do. And then, computer appearance to support the humans to advanced quality of works and make the product become fast and more efficiency. Nowadays, anywhere we can see that computer an indispensable part in the life from company to learn. It make people become more modern. Figure 1.3- 1 : People and technology
- THE SPECIAL THINGS IN COMPUTER AND PROGRAM a) The speacial things in computer Computer is a programmer device that storage , it can regain and access data. The first, it was given to human who performed numerical calculations using mechanical calculators. And after, it was given to a mechanical device as they began remove the human computers. Currently, computers are electronic tool, it will accept data(input), process that data, product output and storage result.
Figure 1.3- 4 : Program Development Process
Chapter 3: INTRODUCTION TO PROCEDURAL PROGRAMMING
Procedural Programming can say the first that new developer will have to learn. Basically, the procedural code is the one in directly instruction a device finish a task in logical step.
1. Simple program
Content: This programming will print one line to say “Hello world” on the screen Process: We will use the “printf” command in C language to call the computer screen to print “Hello World” Figure 1.3- 5 : Flowchart of ”Hello world” Figure 1.3- 6 : Code simple program Figure 1.3- 7 : Result of simple program
3. Contructions
a) Sequence construct Definition: A sequence construct tells the CPU (processor) which statement is to be executed next. By default, it usually following the current statement or in the first program. Figure 1.3- 9 : Sequence construct Example: Figure 1.3- 10 : Example b) Selection construct Definition: Selection construct determines choose the suitable path with condition a program takes when it is running. “if” statement have three forms Form 1: If condition then actions; Form 2: If condition then action 1 else action 2; Form 3: If condition 1 then action 1 else if condition 2 then else if condition 3 then action 3 else if condition 4 then action 4;
Figure 1.3- 11 : If statement Figure 1.3- 12 : code if statement Explanation: See if check my target my subject just equal 5, if it is, the subject is pass or not, the subject is fail c) Switch case statements Definition: The switch case statements is used when we have multiple options and we need to perform a different task for each option.
d) Iteration Structure Definition: it usually called a loop. So, iteration is control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. The purpose of the loop is to repeat the same code a number of times. Figure 1.3- 15 : Iteration Structure For loop: Definition: Loop is used for taken a block of statement iterant for until a given conditions return false with a fixed times of loop. Example: print number from 1 to 10 Figure 1.3- 16 : For loop example While loop: Definition: This is one of the most types of loop repeat a set of instructions based on a condition true. Example: printf from 1 to 10
Figure 1.3- 17 : While loop statement Do While loop: Definition: The do while loop is similar while loop, but the condition is checked after the loop body is execute. This ensure that the loop is run at least once Example: print a table of number 2 using do while loop Figure 1.3- 18 : Do while loop statement
o Pass By Value : the method uses in mode-semantics. Changes made to formal parameter do not get spread turn back to the caller. The formal parameter variable inside the called function or method impact the separate store location and will not be reproduced in the actually parameter in the calling. It called as call by value. Figure 1.3- 21 : Code of Passing Parameter o Pass by References : In this method, changes made to formal parameters to get transmitted back to caller. Any changes to the formal parameter are replicated in the actual parameter in the calling environment as the formal parameter receive a reference (or pointer) to the real data.
7. Modularity
In programing, you split the program into separate sub-programs The code each part does not depend on the other part’s code. If programmers write whole program in just one part, it would not efficient since some code may have to change which has effects on the others. Also, code will much more effective when they set up everything into different parts.
Chapter 4: DESIGN PROCEDURAL PROGRAMMING SOLUTIONS
1. Identify Input, Output
a) In/Out variables Input variables struct student(): to store the object name student with the information as id and grades struct StudentDetail { o Int id; o float grade; }typedef StudentDetail; Int id: IDs of student Float grade: Grade of student StudentDetail student[100]: to store information of list of student Output variables List information of all student Information student with finding by ID Student information who has the highest grade Student information who has the lowest grade b) Main Variables Int for choice: get input user choice from menu Int for n: to store count of list friend Int for index: input index search information Int for id: input id search information Figure 1.3- 22 : Main variables in function