





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Bring a solution for someone who doesn't know how to get M mark. This assignment has a theory about POP, flowchart, and characteristic and evaluates pros and cons of POP
Typology: Assignments
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog 102 : Procedural Programming Submission date 19 /6/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name DNG^ Student ID Class 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
Grade: Assessor Signature: Date: Lecturer Signature:
Table of Figure FIGURE 1 - PROGRAMMING LANGUAGE .................................................................................................................................................... 6 FIGURE 2 - ENIAC ................................................................................................................................................................................ 6 FIGURE 3 - PROGRAMMING LANGUAGES RANKING (SOURCE: WWW.TIOBE.COM) ............................................................................................. 7 FIGURE 4 - CODE PYTHON ...................................................................................................................................................................... 8 FIGURE 5 - EXAMPLE OF PROCEDURAL PROGRAMMING................................................................................................................................ 9 FIGURE 6 - FOR LOOP EXAMPLE ............................................................................................................................................................. 10 FIGURE 7 - COMPARE LOOPS .................................................................................................................... ERROR! BOOKMARK NOT DEFINED. FIGURE 8 - FUNCTIONS IN C LANGUAGES ................................................................................................................................................. 11 FIGURE 9 - HELLO WORD IN C LANGUAGE ............................................................................................................................................... 11 FIGURE 10 - GLOBAL VARIABLE AND LOCAL VARIABLE ............................................................................................................................... 12 FIGURE 11 - MODULAR PROGRAMMING IN C ............................................................................................... ERROR! BOOKMARK NOT DEFINED. FIGURE 12 - PARAMETER PASSING TECHNIQUES IN C .................................................................................... ERROR! BOOKMARK NOT DEFINED. FIGURE 13 - ANOTHER LIBRARIES .......................................................................................................................................................... 13 FIGURE 14 - EXAMPLE FUNCTION .............................................................................................................. ERROR! BOOKMARK NOT DEFINED. FIGURE 15 - DEBUG MODE IN DEV C++..................................................................................................... ERROR! BOOKMARK NOT DEFINED. FIGURE 16 - SWITCH CASE EXAMPLE ....................................................................................................................................................... 17 FIGURE 17 - IF CONDITION ................................................................................................................................................................... 17 FIGURE 18 - FOR LOOP ........................................................................................................................................................................ 18 FIGURE 19 - CODE TO PRINT OUT THE STUDENT'S NAME, GRADE AND ID ........................................................................................................ 18 FIGURE 20 - BUFFER OVERFLOW EXAMPLE .............................................................................................................................................. 19 Table of Diagram DIAGRAM 1 - WBS MANAGE STUDENT ...................................................................................................... ERROR! BOOKMARK NOT DEFINED. DIAGRAM 2 - USE CASE DIAGRAM ......................................................................................................................................................... 20 DIAGRAM 3 - INPUT STUDENTS ............................................................................................................................................................. 21 DIAGRAM 4 - INPUT AND PRINT NAME AND GRADE OF STUDENTS ..................................................................... ERROR! BOOKMARK NOT DEFINED. DIAGRAM 5 - MENU CONTROL .............................................................................................................................................................. 23 DIAGRAM 6 - STUDENT RANKINGS ......................................................................................................................................................... 24 DIAGRAM 7 - FIND MAX GRADE ............................................................................................................................................................ 25 DIAGRAM 8 - FIND MIN GRADE ............................................................................................................................................................ 26
Main content: 1 Introduction: This is the first time I doing an assignment but I will try my best to get an M grade. With the development of social, nowadays, the application of technology is becoming more and more popular. Therefore, it requires students of information technology to improve their knowledge even more. However, to build a solid house, you need a solid foundation. That's why Procedural Programming (PROG102) is a very important subject for an information technology student like me. This course has helped me to understand more deeply about the components of the computer such as CPU, RAM, ROM; Learn more about system numbers like Octal, Hexadecimal and how to convert between system numbers. Also, I know more about how an operating system works. The most special is the C programming language. Although it is an old language, it has helped me understand the steps to solve problems, the syntax, and loops in programming, ... Here It's a huge step for me to learn more about programming in the future. In assignment, I will perform 3 chapter Chapter 1: I will introduce programming languages, procedural programming. And the main functions of procedural programming. Chapter 2: I will present the libraries, variables, statements, and loops that I plan to use in the program and explain how I intend to use them. Chapter 3: I will present the flowchart, work breakdown structure and use case diagram I will use in the program about interpreting them with Pseudo code. 2 Chapter 1: Procedural Programming and Programming Languages
From time immemorial, when humans first appeared on earth, they created language to communicate with each other. Language is used to express one's meaning and feelings towards others, through which people understand each other. As people developed, they also began to create languages that were not used for normal communication, but a way for them to "communicate" with computers. Programming language is a tool we use to create a program for the computer so that the computer follows instructions and produces the results that the programmer wants. The computer will process the programming language in binary form and output the result in the same form. Programming languages will help us translate from binary code to an output that we humans can
The first question most programmers ask is: “What language should we learn first”. But as I mentioned above, a programming language is just a tool to help people and computers understand each other better. Up to now, there are more than 700 different programming languages. It can be mentioned as C, Java, Python, Ruby, C#,... Figure 3 - Programming Languages Ranking (Source: www.tiobe.com)
Each language has its own strengths and weaknesses. Programming languages are used depending on the needs of society. For example, in an era where machines are gradually replacing humans like now, concise and easy-to-understand languages like Python are used a lot because of this language, the rising trend of Machine Learning becomes a booming development. Even big companies like Google or Facebook are creating chatbots and virtual assistants to replace humans.
2.2.1 What is procedural programming and why is it so important? Procedural Programming (POP) is the first basic programming paradigm a new programmer will learn. Essentially, procedural programming is code that directly instructs a device how to complete a task in sequential order. Flowchart of the program's control flow organization. Procedural programming divides the program into functions if the program is too large. A function is simply a subroutine containing a series of steps to be performed. In a nutshell, Procedural Programming is writing a list of instructions for the computer to understand what it must do to complete the task required by the programmer. (Bhatia, 2021) Figure 4 - Code Python
Figure 6 - For loop Example
that employee out to handle. Figure 7 - Functions in C languages
2.2.3 Key features of procedural programming a. Predefined functions Predefined functions are methods that are already defined in the library of the program you are using. However, you can only use statements once you have declared the library. For example, in C language. When you want to print the text "Hello world" to the screen, you need to declare the library "#include<stdio.h>". (Anon., 2014)The sample code would look like this: Figure 8 - Hello Word in C language
Figure 10 - Another Libraries 3 Chapter 2: Analysis for the scenario Scenario : 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. First, we need to generalize the requirements of the scenario as follows:
In this program I plan to use 4 libraries to meet the needs of the problem. That is:
#include <stdio.h>: The basic library of every program in C. For example: Printf,Scanf,gets,... #include <ctype.h>: Library used to check the characters in the student's name #include <string.h>: Library used to use string statements in C such as measuring string length, copy string,... #include <stdlib.h>: Library to avoid warnings for exit() statements
To solve this problem, I plan to use 2 main data types, integer and float. In which variables using integer data type will be used for the number of students, student ID, number of choices in menu control. As follows:
According to the requirements of the problem, we need a loop so that when the user makes a choice, the program will automatically return to the control menu so that the user can continue to choose. Also, there needs to be an option to exit the program so in order to solve that I will use the do-while loop statement. When the block of statements in do is done, the program will return to check the condition in while. If the condition in the while statement is false, the program will continue to run. So, I will set the condition so that the condition in the while statement is true then the program will end. To create a menu control, you must use the switch-case statement to create a menu of options
Figure 11 - Switch case example During the execution of the program, in order to avoid the user entering the wrong number of students, the student's ID and the students' scores, I will use an additional if statement to check the data entered by the user. I plan to use the following: Figure 12 - If condition In addition, I will use an if statement to compare students' scores with each other to find the highest and lowest scores. To be able to test all students I would have to use an extra for loop to
In this will use two nested for loops to print the student's name, score and ID. In addition, to avoid overflowing keyboard memory (Buffer Overflow). I added the statement "fflush(stdin)" Because when the user switches from entering letters to entering digits, the computer will overflow. Therefore, this command is required to clear the keyboard cache before the user continues to enter data from the keyboard. Figure 15 - Buffer Overflow Example Since the loops and statements are quite long, I cannot cover all the examples I intend to include in this assignment, so I will only take a few examples to explain my program. But don't worry, I'll cover and explain it fully in chapter 3 in the form of a flowchart. 4 Chapter 3: Design the solution to the problem
Diagram 1 - Use Case Diagram
As mentioned above to be able to understand more about the guessing algorithms behind the program's functions, we need to add flowcharts to be able to better understand that. To be able to explain in detail, I will have 6 flowcharts to explain the problems of: Enter student number, enter student's grade and name, menu control, student rankings, find max grade and find min grade. 4.2.1 Input number student To be able to enter the number of students, we need to have an indispensable condition that the number of students must be greater than zero. Because there cannot be a single student or the number of students is negative. Here is my diagram.