Computer Programming: Understanding Functions and Procedural Programming, Assignments of Information Technology

An introduction to computer programming, focusing on the concept of functions and procedural programming. It covers the basics of programming, the role of functions, and the process of developing a simple program using C language. The document also explains the use of global and local variables, selection constructs, and iteration statements. Students will learn how to write and declare functions, as well as the difference between standard library functions and user-defined functions.

Typology: Assignments

2019/2020

Uploaded on 11/28/2020

nguyen-tan-khoi-fgw-dn
nguyen-tan-khoi-fgw-dn 🇻🇳

2 documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1 |
NGUYEN TAN KHOI
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
GCD191160
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
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Computer Programming: Understanding Functions and Procedural Programming 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
      1. INTRODUCTION
      1. THE SPECIAL THINGS IN COMPUTER AND PROGRAM
      • Chapter 3: INTRODUCTION TO PROCEDURAL PROGRAMMING
        1. Simple program...........................................................................................................................................
        1. Variable
        1. Contructions................................................................................................................................................
        1. Function
        1. Value passing (parameter)
        1. Parameter passing (Pointer)
        1. Modularity
      • Chapter 4: DESIGN PROCEDURAL PROGRAMMING SOLUTIONS
        1. Identify Input, Output
        1. The required construction for the Management solution..........................................................................
        1. Hierachical diagram of the program
        1. Use-case diagram
        1. Flow Chart Diagrams
      • Chapter 5: REFERENCES
      • Chapter 6: INDEX OF COMMENT
  • Figure 1.3-1: People and technology Table of Figure
  • 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.........................................................................................................................
  • Figure 1.3-27: Enter List student Function
  • Figure 1.3-28: Display student
  • Figure 1.3-29: Display student detail
  • Figure 1.3-30: Find highest
  • Figure 1.3-31: Find lowest
  • Figure 1.3-32: Switch-case Statement in math
  • Figure 1.3-33: if statement in math
  • Figure 1.3-34: For Statement
  • Figure 1.3-35: Do-while loop
  • Figure 1.3-36: Hierachical diagram of the program....................................................................................................
  • Figure 1.3-37: Use-case diagram
  • Figure 1.3-38: Flow Chart Diagrams

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)

Nguyen Tan Khoi

Assignment 1

Chapter 2: PRINCIPLES OF PROCEDURAL PROGRAMMING

  1. 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
  2. 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- 2 : Computer

b) Computer Program Computer programming is way make computer can understand the things humans want to do. It is like a guide for computer. Guide can known as code, and computer programmers write code to solve problem or perform a specific task. Figure 1.3- 3 : Computer program c) What is coding and how can computer work?  What is the coding? Code is types of coding languages used by programmer to get a computer to behave anything you want it make. If fill of full line of code, it called a script.  Program develop process  Step 1: Problem Definition  Step 2: Program Design  Step 3: Coding  Step 4: Debugging  Step 5: Testing  Step 6: Documentation  Step7: Maintenance

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

2. Variable

 Defenition of variable : datatype variable ;  Local variable: it was laid inside a function or block. Specially, it is declared override the same variable name in the larger scope and just used with same name but different function.  Global variables: global variables meanings visible and outside any function and they use it on any function in the program. Figure 1.3- 8 : Global and variables  Global variables are declared outside any function, and they can be accessed (used) on any function in the program. For example, variable a in line 4 is a global variable, and then it can be accessed by all the function in the program  Local variables are declared inside a function, and can be used only inside that function. It is possible to have local variables with the same name in different functions. For example, b in line 9 is a local variable and then it can be accessed only inside the function my_test().  Even the name is the same, they are not the same. It's like two people with the same name. Even the name is the same, the persons are not.

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.

Figure 1.3- 13 : Switch case statement  Example: it’s very useful when you out of the switch body. Whenever “break” statement is encountered in the switch body, the control comes out of the switch case statement. Figure 1.3- 14 : Code switch-case

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

4. Function

 Definition: A function is a block of statements that performs a specific task. Suppose you are building an application in C language and in one of your program, you need to perform a same task more than once  Function declaration syntax: return_type function_name( parameter list ); Figure 1.3- 19 : Function declaration syntax  Type of Functions: 2 types  Standard library functions  User-defined functions Figure 1.3- 20 : Library function and user-defined function

5. Value passing (parameter)

 A value parameter is a formal parameter identification a memory location that is set aside while the procedure is dynamic, and into which the contents of an actual parameter will be copied at the time the procedure is called

6. Parameter passing (Pointer)

 There are different ways in which parameter data can be passed into and out of methods and functions.  Important of method Parameter passing

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

c) Switch case/selection variables Figure 1.3- 23 : Choice menu function Use the switch case to declare the integer value to get the user’s choice from the keyboard and process. A menu must use a switch case because there are too many different options for menu.

d) Sub functions and hierarchy diagram of the program

 Function input ID:  Local variable: int id Figure 1.3- 24 : input ID Function  Function inputgrade:  Local variable: float grade Figure 1.3- 25 : Input local variable function