0% found this document useful (0 votes)
95 views14 pages

Analysis and Design A Solution For Procedural Programming Problem

The document describes the implementation of a C program to store student IDs and grades based on a previous design. Key aspects include: 1. Declaring necessary libraries and variables like integer arrays for IDs and grades. 2. Creating functions for the menu, inputting data, displaying student lists, and finding the highest grade. 3. Using loops, conditional statements, and arrays to validate input, store data, and output results. 4. Following coding standards and commenting code for readability and future maintenance. The program is tested with different data and edge cases to evaluate performance and identify areas for improvement. Procedural programming techniques are applied to effectively solve the given problem.

Uploaded by

Duy Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views14 pages

Analysis and Design A Solution For Procedural Programming Problem

The document describes the implementation of a C program to store student IDs and grades based on a previous design. Key aspects include: 1. Declaring necessary libraries and variables like integer arrays for IDs and grades. 2. Creating functions for the menu, inputting data, displaying student lists, and finding the highest grade. 3. Using loops, conditional statements, and arrays to validate input, store data, and output results. 4. Following coding standards and commenting code for readability and future maintenance. The program is tested with different data and edge cases to evaluate performance and identify areas for improvement. Procedural programming techniques are applied to effectively solve the given problem.

Uploaded by

Duy Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

ASSIGNMENT 2 :

Analysis and Design a solution for


procedural programming problem

Student name: Bui Duy Trung


Id: GCS210515
Class: GCS1003B
Instructor: Le Ngoc Thanh

1
ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing


Unit number and title PROG102: Procedural Programming
Submission date 07/07/2022 Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Bui Duy Trung Student ID GCS210515

Class GCS1003B Assessor name Le Ngoc Thanh

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:

Grade: Assessor Signature: Date:


Lecturer Signature:

3
Assignment Brief 2 (RQF)
Higher National Certificate/Diploma in Computing

Unit Number and Title Procedural Programming


Academic Year 2021
Unit Tutor
Assignment Title Analysis and Design a solution for procedural programming problem
Issue Date
Submission Date
IV Name & Date

Learning Outcomes and Assessment Criteria

Pass Merit Distinction

LO3 Be able to implement procedural programming solutions


LO4 Be able to test procedural programming solutions

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.

P5 Test the program with M4 Analyse test results for future


proper test plan. maintenance.

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.

1.1.4 Select an option:


- I use the switch function to split the selections into 5 sections, each with its own task.
- I first let the user choose the function by having the user change the numeric value of the selection()
variable.

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.

1.1.5 Input student information:

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

1.1.6 Display list of student:

- 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:

Input student information:

Print out list of student:

10
Find the student has highest grade:

Find the student has lowest grade:

Exit the program:

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,#,$)

3 Input Letter, Program error Fail


grade characters(a,b,#,$)

4 Find the Student 1: 10 Student 1: 10 Pass


student Student 2: 3
has the Student 3: 8
highest
grade
5 Find the Student 1: 10 Student 2: 3 Pass
student Student 2: 3
has the Student 3: 8
lowest
grade
6 Display Student 1: 10 Student 1: 10 Pass
list of Student 2: 3 Student 2: 3
student Student 3: 8 Student 3: 8

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]

KnowledgeBoat. 2022. What are the characteristics of procedural programming?|KnowledgeBoat.


[online]
Available at: https://www.knowledgeboat.com/question/what-are-the-characteristics-of-
procedural-programming--28311496451138200
[Accessed 20 February 2022]

Tutorialspoint.com. 2022. C - Data Types. [online]


Available at: https://www.tutorialspoint.com/cprogramming/c_data_types.htm
[Accessed 20 February 2022]

Docs.microsoft.com. 2022. Overview of C Statements. [online]


Available at: https://docs.microsoft.com/en-us/cpp/c-language/overview-of-c-
statements?view=msvc-
170#:~:text=C%20statements%20consist%20of%20tokens,is%20discussed%20in%20this%20section.
[Accessed 20 February 2022].

Programiz.com. 2022. C for Loop (With Examples). [online]


Available at: https://www.programiz.com/c-programming/c-for-loop
[Accessed 20 February 2022].

En.wikipedia.org. 2022. Work breakdown structure - Wikipedia. [online]


17Available at: https://en.wikipedia.org/wiki/Work_breakdown_structure
[Accessed 20 February 2022].

En.wikipedia.org. 2022. Flowchart - Wikipedia. [online]


Available at: https://en.wikipedia.org/wiki/Flowchart
[Accessed 20 February 2022].

Cuemath. 2022. Conditional Statement - Cuemath. [online]


Available at: https://www.cuemath.com/data/conditional-statement/
[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].

Programiz.com. 2022. C while and do...while Loop. [online]


Available at: https://www.programiz.com/c-programming/c-do-while-loops
[Accessed 20 February 2022].

14

You might also like