Assignment1 for programing C Language, Assignments of C programming

Your next task is to do the analysis for the scenario mentioned above by doing the following subtasks. Analysis the problem and explain: - List variables, data types, data structures needed in the problem - Conditional statements needed in the problem - Loop statement needed in the problem

Typology: Assignments

2020/2021

Uploaded on 09/18/2021

le-linh-dan
le-linh-dan 🇻🇳

4.5

(22)

9 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LeThiPhuongAnh_GCH200052 1
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
Le Thi Phuong Anh
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
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Assignment1 for programing C Language 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 Prog 102 : Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Le Thi Phuong Anh 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

Table of Contents

  • I INTRODUCTION
  • I.1 Programming language
    • I.2 Procedural Programming
      • I.2.1 General concepts
    • I.3 Problem statement
    • I.4 Problem solving
    • I.5 Application of procedural programming to this program
  • II ANALYSIS
    • II.1 List variables, data types and data structures needed in the problem
      • II.1.1 Variables
      • II.1.2 Data types, data structures
    • II.2 Conditional statements needed in the problem
    • II.3 Loop statement needed in the problem
  • III. DESIGN
    • III.1 WBS
    • III.2 Flowcharts
      • III.2.1 Use-case
      • III.2.2 Flowchart
  • IV EVALUATION
    • IV.1 Lessons learned
    • IV.2 Future improvement
  • V CONCLUSION
  • Reference list

I INTRODUCTION

I.1 Programming language Nader (2020) commented that Programming Language could be a programming dialect is the set of informational through which humans interact with computers. In other words, according to Beal (2021, a programming dialect is the language of a computer, having a place to a framework that permits its clients to type in particular computational programs or algorithms. When individuals communicate with each other, we utilize language to communicate information. In any case, computer systems and program don't get it our language, so they require another dialect to function, making these devices' get it ' and work concurring to our wishes. Those are programming languages. Research by Nader (2020) shows that the uncommonly most reliable computers were truly adjusted by changing ones and zeros physically, substituting the circuit and the wiring. Of course, it was not straightforward to create various programs as most were utilized for specific applications because it were, and they were colossal in degree so they were exceptionally confined. It is fought that’s why the creation of programming lingos was a dynamic step that took the field to another level and not at all like standard tongues, watchwords in programming lingos are constrained, and by combining these watchwords, architects are able to create assorted sorts of programs. There are unprecedented pieces of computer program that turn the code you sort in into machine lingo that the machine gets it. So, what is programming tongue? In brief, a programming tongue is the set of educational through which people related with computers. Today in the world, there are many programming languages, each with its own characteristics and properties leading to different advantages and disadvantages. We can understand that there will be no language that can be used. There is no such thing as "the best programming language" and there is no such thing as "the worst language" because each language has its own tasks and unique features. Over time, languages have changed and upgraded to suit the environment. So, we need to learn many different languages so that we can keep up with the times and apply it to our lives

I.2 Procedural Programming I.2.1 General concepts According to a study by Harvey (2013) Procedural Programming could be a term utilized to represent the way in which a computer software engineer composes a program. This strategy of creating program, which too is called an application, revolves around keeping code as brief as conceivable. It moreover centers on an awfully particular conclusion result to be accomplished. Bhatia (2021) states that essentially put, Procedural Programming includes composing down a list of instructions to tell the computer what it ought to do step-by-step to finish the errand at hand. As the name suggest, the procedural programming the program code is organized within the shape of strategies. These procedures are moreover called as subroutines or function. I.2.2 Characteristics In a recent study by Learn Computer Science (2021), insights appear estimations showed up the procedural programming focuses at apportioning the tremendous program into smaller programs called strategies. The strategies are additionally at that point once more insinuated to as subprograms, subroutines, techniques of capacities. And a in that the program code is organized as set of strategies called work. These capacities work on the program data called the variables. Data to boot inside the outline of variables. The capacities work on the program data. Each work comprises of computational clarifications and understands a parcel of the issue. Image 3 : Function

Image 4: Function declaration Learn Conputer Science( 2021 ) noted that The procedural programming code is composed as course of action of subroutines ( work or strategies). They can either be definded into the most program code or outside the foremost program code into a disconnected header record. Other than, in procedural programming , when the program appraise is becom gigantic at that point the program code is portion into bunch of humbler programs called methods or subroutines. Image 5: Programming Organization

Example of procedural programming: Image 6: Structure of Procedural programming The C procedural language is extensively used in the industry for the system programming. Image 7: Hello world - programming Language C

I.3 Problem statement A teacher needs to manage the grades of students in the class. To avoid data confusion, student omission or time-consuming problem retention, we should design a program. Thus, through that program, teachers will easily manage students without worrying about problems. At the same time, you can also edit and search for student information in the fastest way. I.4 Problem solving To solve the problem, a program will be designed to help math teachers manage students' grades. He just needs to enter the student's information including ID, name, gender, age, grades. The program will display the entered information on the screen. At the same time, some basic functions appear on the screen such as searching for the student with the highest score, the student with the lowest score, calculating the average score and displaying a list of students by average score and deleting students by ID. Thus, there is no need to spend a lot of time and effort on entering scores and storing information. I.5 Application of procedural programming to this program Based on procedural programming, a program will be designed according to the struct structure in C programming language to help math teachers manage students' grades. Procedural programming is a complete option in setting up a student score management program.

  • To implement functions in the program, first declare library functions: #include <stdio.h> , #include <string.h> , #include <stype.h> , #include <conio.h>.
  • Next, I will use struct - another user-defined information sort accessible in C that permits combining information things of distinctive sorts. As such, we enter a lot of information of many students.
  • Next step, initialize and declare all the data types I use for my program: int, char and float to declare ID, ten, score, ... and then write the following functions one by one.
  • Create void , float functions using conditional statements, loop statements: if, if-else, for, while, do/while and operators.
  • Finally: declare a main function. The most work is where the code will be run to start with, compile the program, the substance within the essential work will be run to start with, in any case of its position inside the record. In organize for the client to select enunciations, I utilize a switch case division & control structure in C to appear the choices menu and exit the program. In brief, through procedural programming, things have gotten to be simpler. A program with essential C programming capacities planned to assist instructors oversee understudy grades.

II.1.2 Data types, data structures Within the C programming language, data types sorts constitute the semantics and characteristics of capacity of data elements. They are communicated within the language structure in frame of statements for memory areas or factors. Data types too decide the sorts of operations or strategies of preparing of data elements. Here are a few fundamental data types

  • int is an integer (2,56,38,20, …)
  • float and double are used for floating point numbers. The float type (real number) takes up 4 bytes and can have up to 6 decimal places, whereas double takes up 8 bytes and can have up to 10 decimal places.
  • char takes up 1 byte and is capable of storing a single character (character).
  • bool C language does not support bool type, but it uses integer to represent true/false (0 means false, non-zero means true).
  • void : is typically used to declare a function that returns no value. A data structure could be a named area that can be utilized to store and organize data. In other word, a data structure may be an information organization, administration, and capacity arrange that empowers productive get to and alteration. Here are some data types used in the student management program: Image 9 : Example of data types The program needs to enter the information of many students with many different data types. A suitable way is to use struct. Because it allows us to declare different types of elements in it.

Explain why use data types for each variable: Data type Variables Value int ID, age We see that ID (identification) are integers (example: 200052) so we will use int data type char name, gender The name with gender is a array of characters (LeMinhPhuong or female), so we choose char data type float assignment, test, exercise, average, max, min For variables like assignment, test, assignment, average, min, max, it's the student's score. It can be stored as real numbers (example: 2.5, 9.0, 7.9, ...) so we use float data type bool true Use in switch-case function. After input info of students first, we set it is true , so that, another case can use. If we were not input info first, check would be false , so one notification will warn you to input info first. II.2 Conditional statements needed in the problem Conditional Statements in C programming are utilized to create choices based on the conditions. Conditional statements execute consecutively when there's no condition around the statements. On the off chance that you put a few conditions for a block of statements, the execution stream may alter based on the result assessed by the condition. This prepare is called decision making in 'C'. In 'C' programming there are two common constructs:

  • If statement
  • If – else statement If statement is always utilized with a condition. The condition assesses to either true or false. True is a non- zero esteem, and untrue may be a esteem that contains zero and and the if statement will execute the line of code within the explanation, in case the condition is true. Therefore, the if statement is used to find conditions in statements such as finding min, max average scores, conditions to sort students by scores and delete students.

Image 1 3 : Example about nested if-else statement The if..else..if articulation permits executing a piece of code between different choices. But on the off chance that we checking the esteem of a single variable in an if...else..if articulation, the switch case could be a way better choice. Employing a switch case will make our code less demanding to type in and simple such as selecting the case to print to the screen Image 1 4 : Example of Switch Case The switch - case branching structure is often used to replace the if - else structure when there are too many options to choose from, especially in the situation that there are 7 choices in the menu of the program. So this means we will have 7 simple if statements or multiple if - else statements nested together. This causes complexity, confusion and verbosity of a program. So here we can use the switch - case statement to overcome this situation.

II.3 Loop statement needed in the problem Agreeing to Union of essential circles in C (2018) when programming we definitely execute a block of code numerous times and the articulations are executed successively: The first statement in a function is executed to begin with, the next statement is the second and so on. Thus, the circle in C issues a case to provide the following types of loops to handle the above repeated requests. Loop can execute a block of code as long as an indicated condition is come to. Loop are convenient since they save time, diminish mistakes, and they make code more discernable. So, I select while loop to make menu choice. While loop will assess the condition. In case the condition is true, the code inside the while loop is executed. The condition is at that point assessed once more. This prepares proceeds until the condition assesses is false. When the condition isn't met, the loop closes. Image 15 : Example of while loop The loop structure causes the program to rehash a sequence of articulations until a certain condition is now not satisfied. In circle structure we utilize do/while. The do/while circle could be a variation of the while loop. To guarantee that there are no blunders this loop will execute the code block once piece once, before checking if the condition is true, then it will repeat the loop as long as the condition is true. Check the expression, in the event that true, repeat execution of the block, if false, end the loop (block is executed once) Image 1 6 : Example of do/while loop

Explain about my program:

  • Input: Enter student information like ID, name, age, gender and score.
  • System: According to the commands, the program will calculate the average score, sort the students by the descending score, sort the students based on the average score, and delete the students
  • Output: Print out the class list including name ID, gender, age and ranked from high to low, show the screen the student with the highest score, the student with the lowest score, based on the average score will classify students and delete students by ID. III.2 Flowcharts To better understand the program and the functions performed, let's follow the use-cases and flowcharts. III.2.1 Use-case Through use cases, we somewhat understand the program better. Use cases describe the typical interaction between the external user (teacher) and the system. Also describe the requirements for the system. Image 1 7 : Use-case

III.2.2 Flowchart This is the flowchart in the student score management program Image 18 : Flowchart for main menu