Docsity

ASS1 PRO102(DISTINCTION), Assignments of C programming

Toggle sidebar
bg1
1 | P a g e
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
Tran Duc Long
Student ID
GCH210562
Class
GCH1106
Assessor name
Dinh Duc Manh
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
Long
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
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38

Partial preview of the text

Download ASS1 PRO102(DISTINCTION) 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 Prog102: Procedural Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Tran Duc Long Student ID GCH

Class GCH1106 Assessor name Dinh Duc Manh

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 Long

Grading grid

P1 P2 P3 M1 M2 D

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • A- INTRODUCTION.
  • B- TASK 1.......................................................................................................................................................................................................
    • I. Programming Language.
        1. What is Programming Language................................................................................................................................................
        1. Definition...........................................................................................................................................................................................
        1. Features of Programming Language.........................................................................................................................................
        1. Compile..............................................................................................................................................................................................
        1. Interpreter.
        1. Types of programming language.
    • II. Procedural Programming................................................................................................................................................................
        1. What is Procedural Programming.
        1. Definition.
        1. Functions.
        1. Key Features of Procedural Programming............................................................................................................................
        1. Code examples...............................................................................................................................................................................
        1. Comparing with Object Oriented Programming(OOP).
        1. Problem statement.
      • a. Business Problem:.......................................................................................................................................................................
      • b. Discuss:............................................................................................................................................................................................
  • C-TASK
    • I. Identify the Variables in the program.
        1. Variables and Declare the Variable.
      • a. Variables:
      • b.Variable Declaration:
        1. Conclude..........................................................................................................................................................................................
    • II. Identify and Describe Selection Structure.
        1. What is the Selection.
        1. Function.
        1. “if...else” statement.
        1. “if...else” ladder
        1. Switch case statement..................................................................................................................................................................
        1. Conclusion.
    • III. Identify and describe loop structs. - 1. loop: for - 2. loop: do…while..................................................................................................................................................................... - 3. Loop While - 4. Conclusion.................................................................................................................................................................................
  • C-TASK 3:
    • I. WBS:
    • II. A use case diagram for actions required.
    • III. Flowchart - 1. Program main:................................................................................................................................................................................ - 2. UserLogin: - 3. Check character is number or letter: - 4. integer and float check
        1. Enter information student:..........................................................................................................................................................
          1. Add a new student and arrange student’s id in ascending order:
          1. Search ID and Grade:
          1. Find students with the highest or lowest score:
          1. Show student’s list:
  • D-TASK 4:
    • Evaluation:............................................................................................................................................................................................... - Choice menu....................................................................................................................................................................................... - Show id and grade, min and max
  • E-Conclusion:
  • Quote:

A- INTRODUCTION.

● We are living in the 4.0 era. Thus, there is a lot of innovation happening every day, particularly

in technology. When it comes to technology, we undoubtedly consider laptops or phones that

have improved our lives. Procedural programming and programming languages also play

significant roles in the interaction between users and computers. Additionally, it is essential in

generating software applications from computers to work and manage in order to make people's

life simpler and easier. Additionally, this contributes to the modernization, advancement, and

development of life.

● In this assignment, I will write in detail about the programming language, procedural

programming, and some of the information I will use to write code, such as variables, conditional

statements, or loops, as well as its function and characteristics.

B- TASK 1

I. Programming Language.

1. What is Programming Language

● Programming Language are exceptional language and it is created to help programmers to write

instruction that allows a machine to perform one or more tasks. (Anon., 2019)

● The vocabulary of computers only includes 1 and 0 (binary).

2. Definition

➢ Abstraction: This is the ability to define and use complicated structures or operations

while ignoring certain details which affect the ability to write. (Anon., n.d.)

➢ Compactness: Using this attribute, operations can be presented in a succinct manner,

without writing too many descriptions. (Anon., n.d.)

4. Compile.

● Compilers are computer programs that translate a high-level programming language to a low-level

programming language. The product of a compiler is an executable file, which is made of

instructions encoded in a specific machine code. Hence, an executable program is specific to a type

of computer architecture. Compilers designed for distinct programming languages might be quite

different; nevertheless, they all tend to have the overall macro-architecture described in the figure

below:

5. Interpreter.

● In computer science, an interpreter is a computer program that directly executes instructions

written in a programming or scripting language, without requiring them previously to have been

compiled into a machine language program.

● The interpreter converts the high-level program into an intermediate language it then executes, or it

can translate the source code at the high-level and then directly execute the commands, which is

done line by line or statement by statement. (Anon., n.d.)

● A high-level language is a programming language designed to streamline programming for

computers. It is called high-level because the central processing unit (CPU) of a computer is quite

a few steps away from the original code running on. High-level source code consists of easy-to –

read structures which are then translated into a low-level language which can only be perceived

and executed by a specific CPU.

● A low-level language is a programming language that deals with elements and limitations of a

computer’s hardware. It either has an insignificant level of abstraction when referring to a machine

or no level of abstraction at all, and it operates to manage the operational meaning of a machine.

II. Procedural Programming.

1. What is Procedural Programming.

● Procedural Programming may be the first programming paradigm that a new developer will learn.

Fundamentally, the procedural code is the one that directly instructs a device on how to finish a

task in logical steps. This paradigm uses a linear top-down approach and treats data and procedures

as two different entities. Based on the concept of a procedure call, Procedural Programming

divides the program into procedures, which are also known as routines or functions, simply

containing a series of steps to be carried out.

Simply put, Procedural Programming involves writing down a list of instructions to tell the

computer what it should do step-by-step to finish the task at hand.

2. Definition.

● Procedural programming is a programming paradigm using a linear approach or a top-down one.

To perform computations it relies on procedures or subroutines.

● Procedural programming is also known as imperative programming.

3. Functions.

● Procedural programming is intuitive in the sense that the way you would expect a program to

work is very similar to that. If you want to do something to a computer, you should give step-by –

step instructions on how to do it. Moreover, most of the languages used to program early on are all

procedural. FORTRAN, COBOL, and C, which have been around since the 1960s and 70s, are

examples of procedural languages.

● It is also uses a list of instructions to tell the computer what to do step by step.

4. Key Features of Procedural Programming.

● Predefined functions: A predefined function is typically an instruction identified by a name.

Usually, the predefined functions are built into higher-level programming languages, but they are

derived from the library or the registry, rather than the program. One example of a pre-defined

function is ‘charAt()’, which searches for a character position in a string.

● Local Variable: A local variable is a variable that is declared in the main structure of a method and

is limited to the local scope it is given. The local variable can only be used in the method it is

defined in, and if it were to be used outside the defined method, the code will cease to work.

● Global Variable: A global variable is a variable which is declared outside every other function

defined in the code. Due to this, global variables can be used in all functions, unlike a local

variable.

● Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are

grouped together to conclude a larger task first. Every group of systems then would have its own

tasks finished one after the other until all tasks are complete.

● Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions,

subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by

reference’, ‘pass by result’, ‘pass by value-result’ and ‘pass by the name’.

language or we may also conclude that it is a method of solving the problem using the tools

and techniques that are accessible to us in a certain way.

Imperative programming describes problem solving as a sequence of steps — do this first, then do

that, then do the next thing, and so on. The machine goes through each line of code, executes it and

continues to the next stage.

5. Code examples.

● Loop in program c:

output:

● Global Variable:

output:

● Parameter Passing:

output:

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.

● Let's analyze the situation:

+Create a list Of students.

+Create a list Of student’s ID.

+Create a list of student's grades.

+Create a function that show all students info.

+Create a function that show student with the highest grade and lowest grade.

+Create a menu so that teacher can choose option.

b. Discuss:

● Today's programming languages are evolving swiftly and forcefully in the growth of science at the

end of the twentieth century and the beginning of the twenty-first century, taking an important

position in the disciplines of science and technology. Management is one of the domains where

computerization is being used extensively in our country. Management programming languages

have aided managers in conducting their work in a scientific manner. The use of information

technology in student administration is critical.

● As a result, programmers frequently write student management software in the C programming

language. We need to undertake a variety of duties and tasks in order to implement the student

management program. As a result, an object-oriented programming program can assist in the

design of this program. Functions and tasks can be readily implemented using functions (or

custom). Furthermore, the functional abstraction (or specialization) of procedural programming

makes it simple for programmers to create programs and simple for users to utilize.

● The usage of loops will assist users in rapidly and effectively locating student scores or searching

for personal information about students.

Example:

Output:

● Users can list the information of the students with the highest or lowest scores by using if else

statements. Years ago, we had to search each page of the paper for student results; now, just type

the student's name to see the results, and this will save a lot of time.

Example:

Output:

2. Conclude.

● Depending on the circumstances, we can declare as many variables and we can assign values to

them as we like, because this is convenient for us in saving time.

It is obvious that in this case I declare two type of data, integer and float. According with that I

also declare 6 variable and that is : a,b,c,x,y,g. The special things here that I declare and assign x,y

with 4,10 at the same time.

I stored variables a,b,x, and y with date type as integer stored c with the character, and stored grade

with a float data type.

● In my project , I use variables the following:

Variable’s name (^) Data type Explanation

1 data[80] struct - I declare “data" array to enter input data

  • I use struct type because it can declare many variables inside.

2 n int - I declare “n” variable to enter students.

  • I use int for this variable as total students is integer.

3 choice int - I declare “choice” variable because “choice” will need to be used

many times in different functions (with the aim of built option.)

  • I use int for this variable because option need be

an integer. It cannot be an odd number.

4 id int - I declare “id” variable to search ID

  • I used int for this variable because id need bean integer.

5 i int - I declare “i” variable because “i” will need to be used many times in

different functions (with the purpose is to loop)

  • I use int for this variable because index need be

an integer.

6 name[40] char - I declare “name" array to enter student's name

  • I use char because name is type characters

7 username[50] char - I declare “username" array to login program

  • I use char because username is type characters

8 password[50] char - I declare “password" array to login program

  • I use char because password is type characters

9 grade float - I declare “grade variable

  • floats can help me enter student mark

10 max float - I declare “max” in local variable because it will need to be used in

one functions(find_max_min)

  • When I use float I can print out the maximum mark with real number.

11 min float - I declare “min” in local variable because it will need to be used in

one functions(find_max_min)

  • When I use float I can print out the minimum

mark with real number.