Docsity

Assignment 1 C language, Assignments of Procedural Law

Toggle sidebar
bg1
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
Phan Minh Tiến
Student ID
GCD201914
Class
GCD1001
Assessor name
Phan Thanh Trà
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
Tiến
Grading grid
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

Partial preview of the text

Download Assignment 1 C language and more Assignments Procedural Law 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 Phan Minh Tiến Student ID GCD

Class GCD1001^ Assessor name Phan^ Thanh Trà

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 Tiến

Grading grid

P1 P2 P3 M1 M2 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • Table of Figure. Table of Contents
  • CONTENT
  • CHAPTER I: AN OVERVIEW OF PROGRAMMING LANGUAGES
      1. PROGRAMMING LANGUAGES
      • 1.1 Definition.
      • 1.2 Types of programming languages
    • 2 C LANGUAGE.....................................................................................................................................................
      • 2.1 Definition
      • 2.2 Structure of a C program.................................................................................................................................
    • 3: PROCEDURAL PROGRAMMING
      • 3.1 Definition
      • 3 .2 Features of Procedural Programming
      • 3.3 Characteristics of Procedural Programming.
      • 3 .4 Advantages and Disadvantages of Procedural Programming.
      • 3.5 Compare Procedural Programming vs Object-Oriented Programming.
      1. THE SOLUTION OF PROBLEM
      • 4.1 Scenario
      • 4.2 Report’s aim..................................................................................................................................................
      • 4.3 Expected Result
  • Chapter II: SCENARIO ANALYSIS
      1. UNIT INITIALIZATION
      • 1.1 VARIABLES
      • 1.2 DATA TYPES
      • 1.3 VARIABLE AND DATA TYPES IN THIS PROGRAM............................................................................
      • 1.4 CONDITION STATEMENT........................................................................................................................
      • 1.5 SWITCH-CASE STATEMENT
      • 1.6 LOOP STATEMENT
      • 1.7 DO-WHILE LOOP STRUCTURE
      • 1.8 FUNCTION
      1. DESIGN SYSTEM STRUCTURE
      • 2 .1 ALGORITHM
      • 2.2 USE CASE....................................................................................................................................................
      • 2.3 FLOWCHART..............................................................................................................................................
      • 2.4 WORK BREAKDOWN STRUCTURE
      1. REVIEW AND EVALUATE THE DESIGN(M2,P2)
  • Reference
  • Figure 1: Programming language Table of Figure.
  • Figure 2: Types of programming
  • Figure 3: The popular programming languages
  • Figure 4: Helloworld in C programming
  • Figure 5: Structure of C programming..........................................................................................................................
  • Figure 6: Procedural programming
  • Figure 7: Pre-defined function
  • Figure 8: Variable
  • Figure 9: Example of pass by value
  • Figure 10: Example of pass by reference
  • Figure 11: Example of pass by name
  • Figure 12: Example of pass by value-result
  • Figure 13: Example of Variable..................................................................................................................................
  • Figure 14: Data Types.................................................................................................................................................
  • Figure 15: Syntax of If statement................................................................................................................................
  • Figure 16: Syntax of else statement
  • Figure 17: Example of if-else statement
  • Figure 18: Syntax of switch-case
  • Figure 19: Flowchart of switch-case
  • Figure 20: Example of switch-case
  • Figure 21: Flowchart of for loop.................................................................................................................................
  • Figure 22: Example of for loop statement
  • Figure 23: Flowchart of do-while loop
  • Figure 24: Example of Do-while loop statement
  • Figure 25: Syntax of function
  • Figure 26: Use-case
  • Figure 27: Flowchart of program
  • Figure 28: Flowchart of validate option......................................................................................................................
  • Figure 29: Flowchart of enterStudentinformation
  • Figure 30: Flowchart of highestGrade
  • Figure 31: Flowchart of lowestGrade
  • Figure 32: Flowchart of print
  • Figure 33: Flowchart of Work breakdown structure...................................................................................................

CONTENT

CHAPTER I: AN OVERVIEW OF PROGRAMMING

LANGUAGES

1. PROGRAMMING LANGUAGES

1.1 Definition.

A programming language is a type of computer language that is used to create software, scripts, or computer instructions.

Today, a variety of programming languages are in use. Although there are parallels between the languages, each has its unique syntax. The programmer's task entails learning the language's rules, syntax, and structure, then writing the source code in an editor or IDE and compiling it into machine language that the computer can understand. Scripting languages don't require a compiler, instead relying on interpreters to run the code.

Figure 1: Programming language

1.2 Types of programming languages

Figure 3: The popular programming languages

2. C LANGUAGE

2.1 Definition

C is a procedural programming language. Dennis Ritchie created the C programming language in 1972 at

AT&T’s(American Telephone & Telegraph) Bell Laboratories in the United States. It was created to

address the shortcomings of prior languages such as B, BCPL, and other. C was created with the intention

of being utilized in the UNIX operating system. Many characteristic of preceding languages such as B and

BCPL are carried over.

In this program, I will use C language to create the application according to the user’s requirements. With

the pros as one of the first programing languages ever developed, C served as the basic for writing more

modern languages. It also an easy language to test, debug and maintain. With the extension of C, C++ was

created that work well for programming the systems that run applications.

Figure 4: Helloworld in C programming

Figure 6: Procedural programming

For general-purpose programming, procedural programming is useful. On the other hand, procedural

programming is difficult to express using real-world objects. Procedure-oriented systems concentrate on

manipulation rather than data, which might pose issues in some data-sensitive situations.

3 .2 Features of Procedural Programming

  • Pre-defined function : A predefined function is typically an instruction identified by a name. Predefined

functions are typically built into higher-level programming languages. However, they are drawn from a

library or registry rather than a program.

+ Example: printf(…) – Send data items to standard output.

Figure 7: Pre-defined function

  • Variable : In simple terms, a variable is a memory-allocated storage location. A variable is a type of data

storage device. Variables of various kinds demand various amounts of memory and have a unique set of

operations that may be applied to them.

+ Example: b234 is variable.

Figure 8: Variable

  • Modularity : When two distinct systems have two separate goals at hand but are joined together to

complete a bigger job first, this is referred to as modularity. Each set of systems would then finish its own

jobs one by one until all tasks were completed.

  • Parameter Passing : Parameter passing is a technique that allows parameters to be sent to functions,

subroutines, or procedures. Parameter passing can be accomplished via ‘pass by value’, ‘pass by

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

+ “Pass by value” - When utilizing this method, any changes to the perimeter are not communicated to the

caller. Changes to the parameter only affect the separate storage location; they have no effect on where the

function is invoked.

Figure 10: Example of pass by reference

+ “Pass by name”- This type of parameter passing can pass the variable's name, allowing it to be accessed

and changed.

Figure 11: Example of pass by name

  • Procedural programming follows a top-down approach, with workflow moving from top to

bottom. It is simple to follow the flow of code in a program developed in the procedural

programming paradigm.

3 .4 Advantages and Disadvantages of Procedural Programming.

Advantages:

 Procedural Programming is excellent for general-purpose programming.

 The coded simplicity along with ease of implementation of compilers and interpreters.

 A large variety of books and online course material available on tested algorithms, making it easier

to learn along the way.

 The source code is portable. Therefore, it can be used to target a different CPU as well.

 The code can be reused in different parts of the program, without the need to copy it.

 Through Procedural Programming technique, the memory requirement also slashes.

 The program flow can be tracked easily.

Disadvantages:

 The program code is harder to write when Procedural Programming is employed.

 The Procedural code is often not reusable, which may pose the need to recreate the code if is

needed to use in another application.

 Difficult to relate with real-world objects.

 The importance is given to the operation rather than the data, which might pose issues in some

data-sensitive cases.

 The data is exposed to the whole program, making it not so much security friendly.

3.5 Compare Procedural Programming vs Object-Oriented Programming.

Procedural Programming Object-Oriented Programming

Uses immutable data Uses mutable data

Follows the declarative programming model Follows the imperative programming model

Extends support to parallel programming Not suitable for parallel programming

The execution order of statements is not the primary

focus

The execution order of statements is very important

Flow control is performed using function calls Flow control is performed through conditional

statements and loops

Uses recursion concept to iterate collective data Uses loop concept to iterate collection data

No such side-effects of its functions The method can have certain side-effects

The focus in Procedural Programming is on ‘What

You are Doing’

The focus in Object-Oriented Programming is on ‘How

You are Doing It’

4. THE SOLUTION OF PROBLEM

4.1 Scenario

A math teacher wants to manage a class’s grades. He ask you to help him to write a small application to

do that. He needs to enter student IDs, student’s grades and store these information into 2 separate arrays

(integer array for IDs and float array for grades). Then he needs to print all student IDs together with their

grades. Finally, he needs to know which student has highest grade and lowest grade. Your program should

Figure 13: Example of Variable

1.2 DATA TYPES

A data type is a categorization in programming that determines the type of value a variable possesses and

the kind of mathematical, relational, and logical operations that can be performed on it without creating an

error. A string for example, is a data type for classifying text, while an integer is a data type for classifying

entire integers.

Figure 14: Data Types

1.3 VARIABLE AND DATA TYPES IN THIS PROGRAM

In this program, there are 8 main variable names that are related to the purpose of the user. Each variable

name would bring its own data type that is suitable for the program.