Analysis and Design A Solution For Procedural Programming Problem
Analysis and Design A Solution For Procedural Programming Problem
1
ASSIGNMENT 2 FRONT SHEET
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 trung
Grading grid
P4 P5 M3 M4 D2
2
Summative Feedback: Resubmission Feedback:
3
Assignment Brief 2 (RQF)
Higher National Certificate/Diploma in Computing
P4 Write a program that M3 Program is written following D2 Evaluate your program, sta
implements the designed coding standards, input data are lessons learnt and future
solution. validated improvements.
4
Assignment Brief
Scenario: Please refer to scenario in Assignment 1.
Tasks 1
Your next task is to implement the software that you designed in previous steps.
You need to implement the software designed in assignment 1 using C programming
language. Your code must make use of programming standards, including file
headers and effective code commenting. You need to provide screenshots of
your program when running. During the development of your program, if you
make any changes to the original design, state them with reasons in report. Your
code listings must be included as an appendix.
Task 2
Test your program by making a test plan, execute it and log results. Your test
plan should include data validation and program operations based on
requirements. Test results (passed or failed) should be analysed to help the
program in future maintenance.
Task 3
Write an evaluation and conclusion of the whole development. The evaluation of
your program should be based on its running and its test result. You should
mention about lessons learnt and future improvement. Also evaluate how
procedural programming is applied in your program, state benefits,
disadvantages or difficulties.
A final report of these 3 tasks must be submitted in PDF format to CMS.
Submission Format
The submission is in the form of a Word document. You are required to make use of appropriate
structure, including headings, paragraphs, subsections and illustrations as appropriate, and all work
must be supported with research and referenced using the Harvard referencing system.
5
TABLE CONTENT
ASSIGNMENT 2 :...................................................................................................................................1
ASSIGNMENT 2 FRONT SHEET........................................................................................................2
Assignment Brief 2 (RQF).......................................................................................................................4
Higher National Certificate/Diploma in Computing............................................................................4
Introduction:.............................................................................................................................................7
1 Implementation (P4,M3)......................................................................................................................7
1.1 Explain:................................................................................................................................................7
1.2 Program results:.................................................................................................................................10
2 Testing(P5,M4)....................................................................................................................................12
2.1 Test evaluation:..................................................................................................................................13
3 Evaluation and conclusion:................................................................................................................13
4 References:...........................................................................................................................................13
6
Introduction:
- In assignment 1, I gave an introduction to procedural programming and successfully design a
program using flowcharts to solve the problem that the scenario gave about building a program that
can store the id, the score of the student. Now, I will explain in more detail how I built this program
with images, tables and most importantly, closely explain the functions of the important command
lines of the program.
1 Implementation (P4,M3)
1.1 Explain:
1.1.1 Library declaration:
- #include<stdio.h> : This library uses what are called streams to operate with physical devices such as
keyboards, printers, terminals or with any other type of files supported by the system. Streams are an
abstraction to interact with these in a uniform way. All streams have similar properties independent
of the individual characteristics of the physical media they are associated with. Most of the C file
input/output functions are defined in this library.
- #include<stdlib.h>: This library defines four variable types, several macros, and various functions for
performing general functions. I use this library for pause screen function, clear screen function and
exit the program.
1.1.2 Variables and Data types:
- Int n: I use “n” to declare the value of the total number of students.
- Int Id[100]: Creating an integer array used to store id of students that user can enters.
- float grades[100]; Creating a float array used to store grades with decimal.
1.1.3 Display Menu:
- I created a MenuDisplay() function using printf() function to create options for the user to use.
7
- Then let the switch function change the functions when the selection() variable changes
- I use do while loop to repeat the user’ selection countless times until user chose to exit the program
(case 5) with exit(0) code.
8
- First, I use a do while loop, which helps the user to input until the number of loops is equal to the
number of students to enter(n). Meaning the loop repeat until I meets the condition I<n.
- In the loop, I let the user enter the student id,”i+1” is used so that the program start to print the 1 st
student instead of the 0th student, then I continue to create a new loop with j variable and Id[j] to
check if the input id exists in the Id[100] array or not. If not, the program will continue to run to the
next statement.
- After the id input is passed, I continue to create a loop to enter the student's grades into the
grades[100] array, with the purpose of checking that the user's entered score is correct with the rule
of greater than or equal to 0 and less more than or equal to 10 or not. If the condition is passed, the
Input() function has completed the task
- I create the for loop with printf() function to repeat printing out One by one value of 2 arrays Id and
grades until the loop equal to the number of students that the user entered before in function 1
(Input()).
- First %d represent the position of the student, the second %d represent a unit of Id[] array, and the
%f represent a unit of grades[] array but only accepted 2 decimal if it was %.2f.
1.1.7 Display a student has highest grade with id:
- I create 3 functions, int Id[100] contains the student id, float grades[100] contains the student's
score and finally the variable n, which represents the number of students that we entered before
(meaning n has task of deciding the number of iterations to repeat). Next, I create a variable max that
represents the student's highest score and this variable will determine the position of information in
each array, for example, the position of max in the grades[] array will implicitly correspond to position
in array Id[]. Given variable max = 0, start the loop with the condition that if max variable value is less
than another value variable then max will be equal to that value. This statement will be executed in a
loop until the variable max value is no longer less than any value variable.
1.1.8 Display a student has lowest grade with id:
9
- Same way to create array, n value to create loop and same strategy to find the maximum value, only
difference is the statement of conditional statement. Make min variable instead of max, make it zero,
put in conditional statement with condition if min variable value in grades[] array is greater than other
value in same array then min will equal it and also get its id in the Id[] array.
1.2 Program results:
Menu:
10
Find the student has highest grade:
11
2 Testing(P5,M4)
Test What’s Input Result Evaluate
case being test
1 Input Letter, Program error Fail
number characters(a,b,#,$)
of student
2 Input Id Letter, Program error Fail
characters(a,b,#,$)
12
2.1 Test evaluation:
- Test plan: 3 pass, 3 fail
- Number of student and Id part when entering letters, the program instantly error because there is
no condition that allow characters to be entered. Grades con be enter with decimal number but the
same thing happened when enter letters and special characters.
3 Evaluation and conclusion:
- In my opinion, my program was able to successfully complete 80% of the work it was assigned to do,
import, store and export. But it still has a lot of limitations such as not being able to enter letters or
special characters leading to unsuccessfully storing student names. Besides, in the future I will learn
more and maybe develop more useful functions such as creating user accounts or storing information
directly on a widely shared server, until the program is closed and reopening process, we do not need
to enter student information again.
- After the course, I can relatively understand what procedural programming is, I can apply procedural
programming to solve problems, successfully understand how to code a program and finally created a
first small product that can run.
4 References:
En.wikipedia.org. 2022. Procedural programming - Wikipedia. [online]
Available at: https://en.wikipedia.org/wiki/Procedural_programming
[Accessed 20 February 2022]
Career Karma. 2022. What is Procedural Programming, and When Should You Use It?. [online]
Available at: https://careerkarma.com/blog/procedural-
programming/#:~:text=When%20you%20use%20a%20procedural,from%20a%20top%2Ddown%20vie
13
w.
[Accessed 20 February 2022].
14