Docsity

Assignment 1 (P, M) - C Programming - Vo Minh Quoc, Essays (university) of C programming

Partial preview of the text

Download Assignment 1 (P, M) - C Programming - Vo Minh Quoc and more Essays (university) C programming in PDF only on Docsity!

ASSIGNMENT 2

Analyze and design a solution for procedural programming problem.

ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PROG102: Procedural Programming Submission date 30/6/2021 Date Received 1st submission Re-submission Date 4/7/2021 Date Received 2nd submission Student Name Vo Minh Quoc Student ID GCD Class GCD0904 Assessor name Phan Thanh Tra 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 (^) Quoc Grading grid P 4 P 5 M3 M4 D

Table of Contents

  • 1 INTRODUCTION
    • 1.1 Problem
    • 1.2 Solution
    • 1.3 Coding standard:
  • 2 IMPLEMENTATION (P4, M3)
    • 2.1 Structure of program
    • 2.2 Function and how each function is used in program
    • 2.3 Important algorithms in program
  • 3 PROGRAM RESULTS (P4)...............................................................................................................................
  • 4 TESTING (P5, M4)
    • 4.1 Test plan:.....................................................................................................................................................
    • 4.2 Test log
    • 4.3 Test result analysis
  • 5 EVALUATION (D2)
    • 5.1 The program’s evaluation , state lessons learned, and future improvements..............................................
    • difficulties) (Anonymous, n.d) (Bhatia, n.d).......................................................................................................... 5.2 The evaluation of how procedural programming is applied in program (advantages, disadvantage,
  • 6 Bibliography
  • Figure 1. Case diagram of the program
  • Figure 2. Declare libraries
  • Figure 3. Declare data types and variables
  • Figure 4. Function
  • Figure 5. Function input information of students
  • Figure 6. Function output information of students
  • Figure 7. Function menu option of program
  • Figure 8. Function menu option of program
  • Figure 9.Finding max grade...........................................................................................................................................
  • Figure 10.Function menu option of program
  • Figure 11. Function menu option of program
  • Figure 12. Flowchart of finding the highest grade
  • Figure 13. Flowchart of finding lowest grade.
  • Figure 14. Exit Program
  • Figure 15.Menu option
  • Figure 16. Choice 1......................................................................................................................................................
  • Figure 17. Choice 2......................................................................................................................................................
  • Figure 18. Choice 3......................................................................................................................................................
  • Figure 19.Choice
  • Figure 20. Choice 5......................................................................................................................................................

o <string.h> : To adjust a variety of character ranges. Figure 2. Declare libraries

  • Declaring variables used in program. I declared local variables below:
    • Integer: id (is the ID of students), thenumberofStudent ( is the number of students), b, c.
    • Float: gradeofstudent (is the grade of students). Figure 3. Declare data types and variables
  • Using function I used three functions:
  • Function “inputInformation”: is used to input ID and grade of students.
  • Function “outputInformation”: is used to display ID and grade of students.
  • Function “main”: is menu option. Figure 4. Function 2.2 Function and how each function is used in program
  • Function “inputInformation()” has function to help the math teacher to enter ID and grade of students and check that if both of them are valid or not via “array” to store them, “for” loop and “do…while” loop. Furthermore, it has ability to check if ID and grade of students are duplicated or not. After that, it forces the math teacher to input each of them again.

Figure 5. Function input information of students

  • Function “outputInformation” helps the math teacher to display the grade corresponding to the ID respectively which are stored previously from function “inputInformation” via “for” loop. Figure 6. Function output information of students
  • Function “main()” is the menu option used for outputting five choices including:
    • Exit program.
    • Input information of student.
    • Output information of student.
    • Display IDs have highest grade.
    • Display IDs have lowest grade.
    • Re-enter the number of students if you enter wrong.

Figure 9 .Finding max grade..

  • Case 3: Help you find the students has the highest grade and print to the screen.
    • max = gradeofStudent[0], idofmax = id[0]
    • b from 0 to (thenumberofStudent - 1 )
    • If max < gradeofStudent[b] then max = gradeofStudent[b], idofMax = id[b]
    • Print the result on the screen. Figure 10 .Function menu option of program
  • Case 4: Help you find the students has the lowest grades and print to the screen.
  • min = gradeofStudent[0], idofMin = id[0]
  • b from 0 to (thenumberofStudent - 1 ).
  • If min > gradeofStudent[b] then min = gradeofStudent[b], idofMin = id[b]
  • Print the result on the screen Figure 11. Function menu option of program
  • Case 5 : I used “do…while” loop combined to “if” statement to repeat entering student numbers if the teacher enters data outside the condition. 2.3 Important algorithms in program
  • Find the highest grade of student:
  • max = gradeofStudent[0], idofmax = id[0]
  • b from 0 to (thenumberofStudent - 1 )
  • If max < gradeofStudent[b] then max = gradeofStudent[b], idofMax = id[b]
  • Print the result on the screen.
  • b from 0 to (thenumberofStudent - 1 ).
  • If min > gradeofStudent[b] then min = gradeofStudent[b], idofMin = id[b]
  • Print the result on the screen Figure 13. Flowchart of finding lowest grade.
3 PROGRAM RESULTS (P4)
  • Screenshot:
    • Exit program: Figure 14. Exit Program
    • Menu option: Figure 15 .Menu option
    • Input ID and grade of students: Figure 16. Choice 1
4 TESTING (P5, M4)

4.1 Test plan:

TES
T P
LAN

Test case ID Task name Task description Start date End date Estimated Efforts(Hrs/day) 1 The number of student (int a) (3<a<50) Enter valid data and invalid data into the number of student 30/06/2021 30/06/2021 1 Hour 2 Grade of students (float grade[100]) Range: 0 to 10 Enter valid data and invalid data into the number of student 3 ID of students (int ID[100]) Enter valid data and invalid data into the number of student 4 Menu option. Range: 0 to 5 (Test five option) Enter valid data and invalid data into the number of student

4.2 Test log Test case ID Test case Input data Expected results Actual results Evaluation 1 The number of student (int a) (3<a<50) Letter: A, b, c, … The program will run infinitely. As in the screenshot below. Pass Special character: !, @, ?, … The program will run infinitely. As in the screenshot below. Pass

Integer outside the condition The program will notify users that they have entered it incorrectly and invite them to re- enter it. As in the screenshot below Pass Decimal: 1.1, 1.2, … The program will run infinitely. As in the screenshot below Pass 2 Grade of students Letter: A, b, c, … The program will run infinitely. As in the screenshot below Pass

(float grade[100]) Range: 0 to 10 Special character: !, @, ?, … The program will run infinitely. As in the screenshot below Pass