Download Procedural Programming: Analysis and Design of a Grade Management Solution and more Assignments C programming in PDF only on Docsity!
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Phan Minh Tri Student ID GCD Class PROG102 Assessor name 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 P3 M1 M2 D
Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date: Lecturer Signature:
Table of Contents
- I. PROBLEM DESCRIPTION
- SENARIO
- REPORT GOALS..................................................................................................................................................
- II. SOLVING GIVEN PROBLEM
- PROGRAMMING LANGUAGES
- C language
- 2.1. Definition
- 2.2. History of C language
- Key features of procedural programming
- 3.1. Procedural programming paradigm..........................................................................................................
- 3.2. Predefined functions.................................................................................................................................
- 3.3. Variables
- 3.4. Modularity
- 3.5. Parameter passing
- 3.6. Procedures
- 3.7. Advantages and Disadvantages of procedural programming.................................................................
- 3.8. Conclusion
- III. SCENRIO ANALYSIS
- Variables and Data Types................................................................................................................................
- 1.1. Variables
- 1.2. Data types
- Conditional statement
- 2.1. “If” statement function
- 2.2. “If – Else” statement function.................................................................................................................
- 2.3. “Switch case” statement function
- Loop statement
- 3.1. “For” statement function
- 3.2. “Do – while” statement function
- Functions.........................................................................................................................................................
- IV. DESIGN
- Use-case diagram
- Flowchart
- V. REVIEW AND EVALUATE THE DESIGN
- Figure 1: Some popular programming languages Table of Figures
- Figure 2: C programming language logo
- Figure 3: IEEE-the best 10 top programming language in
- Figure 4: History of C language
- Figure 5: Procedural programming paradigm...............................................................................................................
- Figure 6: Predefined functions....................................................................................................................................
- Figure 7: Example of global variable and local variables
- Figure 8: Data types in C language..............................................................................................................................
- Figure 9: Variables and Data types in this program
- Figure 10: Example for using "if" statement function
- Figure 11: Example of using "if-else" statement function
- Figure 12: Hierarchy diagram program.......................................................................................................................
- Figure 13: : Example of using "switch case" statement function
- Figure 14: Example of using "for" statement function
- Figure 15: Example of using "Do-while" statement function
- Figure 16: Use case diagram
- Figure 17: Flowchart diagram
- Figure 18: Option input
- Figure 19: Option display
- Figure 20: Option find highest grade
- Figure 21: Option find lowest grade
Figure 1 : Some popular programming languages (M.Saqib, 2020) Note: Many languages share similarities, but each has its own syntax. Once the programmer has learned the rules, syntax, and structure of the language, he creates the source code in a text editor or IDE. Programmers then often compile the code into a machine language that the computer can understand. Scripting languages that do not require a compiler use an interpreter to execute scripts. (Computer Hope,
- (Computer Hope, 2021)
- C language Figure 2 : C programming language logo (Britefish, 2021) 2.1. Definition C programing language is a very popular, easy and flexible to use general-purpose programming language. “C” can be said to be the basis of programming. Knowing “C”, you can easily grasp the knowledge of other programming languages that use concept of “C”. (GURU99, 2021)
Figure 3 : IEEE-the best 10 top programming language in 2018 (GURU99, 2021) 2.2. History of C language The C programming language is a programming language developed in 1972 by Dennis Ritchie and Brian Kernighan of Bell Labs in a little-known language called B. The first major software written by C was the Unix operating system, and for many years C has been thought of as: Inseparable relationship with Unix. Figure 4 : History of C language
Figure 6 : Predefined functions (Kabir, 2021) 3.3. Variables 3.3.1. Local variables Local variables are variables declared in the basic structure of a method and are limited to the territory. Local variables can only be used in defined methods, and if used outside of defined methods, the code will not work.
Figure 7 : Example of global variable and local variables 3.3.2 Global variables Global variables are variables that are declared outside of all other functions defined in the code. This allows global variables to be used in all functions, unlike local variables. 3.4. Modularity Modularity is when two different systems have two different tasks, but they are grouped together to get the bigger task done first. This causes all system groups to complete their own operations in sequence until operations are complete. 3.5. Parameter passing Parameter passing is the mechanism used to pass parameters to a function, subroutine, or procedure. Parameter passing can be done through ‘pass by value’, ‘pass by reference’, ‘pass by results’, ‘pass by value-result’ and ‘pass by the name’. 3.6. Procedures if there is a programming procedure, the program that contains the procedure follows the procedure step by step and systematically. The program executes the commands exactly as they as they are executed in the order set by the programmer. 3.7. Advantages and Disadvantages of procedural programming 3.7.1. Advantages
- Procedural programming is suitable for general-purpose programming
- Easy to implement compiler and interpreter and coded simplicity
Name Size (byte) Description Char 1 Store single character information Int 4 Stores numeric data Float 4 Stores values containing decimal places (precision of up to 6 digits) Double 8 Stores values containing decimal places (precision of up to 10 digits) Void This is used to indicate the compiler that there is nothing to expect 1.2. Data types The data type of a value (or variable in some context) is an attribute that indicates the type of data a value can have. In most cases, the term is used in programming languages such as C/C++, Java and C# in connection with static typing of variables, where variable types are notified at compile time. Data types include storage classifications such as integers, floating point values, strings, and characters etc. A data type defines certain characteristics of data used in a software program and tells the compiler about predefined properties required for a particular variable or related data object. (Techopedia, 2021) Figure 8 : Data types in C language (Mishra, 2021)
The following table shows data about these variables, which I will use this program, including their names, data types and its description. Names Data Types Description IDs Int ID of student Grades Float The grades of student N Int The maximum students input in program Current Int The number of student current Choices Int Reporting options that users choose Max Float The highest grades of student Min Float The lowest grades of student Figure 9 : Variables and Data types in this program
2.3. “Switch case” statement function
- At first, the program will evaluate the condition inside “switch” and compare it with the values of each “case” label. Then, if there is match, the statement following the matching label are executed until “break” occur. If no match is found, the default statement is executed. If break is not used, all statements are executed after the matching label.
- In my report, I will use it to declare different options which users choose to report in “Menu”. It will have 4 options:
- Enter the student’s IDs and grades
- Print all information of current student
- Find the highest and lowest grades
- Exit the program
- If I wanted to find the person with the highest or lowest grades, I would choose 3, after finishing, I can choose 1 to enter information of new student or choose 4 to exit the program Figure 12 : Hierarchy diagram program
Figure 13 : : Example of using "switch case" statement function
Figure 15 : Example of using "Do-while" statement function
- Functions
- A function is group of statements that work together. Every C program has at least one function that is main( ), and the most trivial program can define any additional functions.
- You can split the code into different functions. It’s up to you know to split your code into multiple functions, but logically splitting each function is the same as performing a particular task.
- The function declaration tells the compiler about a function’s name, return type, and parameters. A function definition provides the actual body of the function.
- The C standard library provides a variety of built-in functions that your program can call. For example, strcat( ) connects two strings, memcpy( ) copies the memory location to another location and uses more functions.
- Functions may also be called methods, subroutines, procedures, and so on. (tutorialspoint, 2021)
IV. DESIGN
- Use-case diagram Figure 16 : Use case diagram