Sunteți pe pagina 1din 12

Hong Ngc Tun Linh-GCH16483

TASK 1:

Programming Language: A programming language is


a formal computer language or constructed language designed to
communicate instructions to a machine, particularly a computer.
Programming languages can be used to create programs to control
the behavior of a machine or to express algorithms.
(Source: Wikipedia)
Types of Programming Languages: Two types

1. Low Level Languages: Low level languages is languages of


computer and difficult to understand. In low level languages has
two type is Machine language and Assembly language.

Machine Language: Machine language is very hard to


understand but computer can understand quickly and program
can run faster. This language is not easy to learn so a
programmer dont use this to write a program.
Assembly Language: This language is easy to learn with
programmer and it is formal language in programing language.
But assembly language write for a program on one computer
can not run in different computer.
2. High Level Languages: High Level Language is the same with
human language because it not limited by the computer. We can
translate to Machine Language in order to make the computer runs it
and understand.
Program Languages can be divided into four groups:
- Numerical Languages: Early age of computers.
- Business Languages: COBOL.
- Artificial Intelligent Languages: LISP, SNOBOL,
PROLOG.
- Systems Languages: CPL, BCPL, UNIX.
(Source: Problem Solving and C Programming book)
The most important factors that would make a programming
language capable and clear to use:
- Clarity, Simplicity and Unity
- Orthogonality
- Naturalness for the application
- Support for abstraction
- Portability of Programs
- Cost of use
- Cost of Program Maintenance
(Source: Problem Solving and C Programming book)

Procedural Programming:
Procedural Programming Paradigm
Procedural programming mean is a programming paradigm. It
is extracted from structures are the base of all program.
Imperative programming will show us how to accomplish it.
Procedures and modularity
Modularity is the most part attractive. It is particularly in
enormous, complex projects. Its sources of info are generally
planned as contentions and the yields give return values.
Scoping: You can think sco ping is rule to protect and keeping
modular from the action of accessing the variables.
Procedures can do a simple interface and reused. It is a
convenient tool for making pieces of code written or group,
including programming libraries.
Comparison with imperative programming
Procedural programming language is also imperative
languages. It give the required computer to computer run
smoothly during instruction.

TASK 2:
2.1 Identify the program units and data and file
structures required to implement a given design:
a. Variables and data types required:
Variable: In programming, a variable is a place in memory where
you can store information. Its like a little box or bucket to put stuff
in. At any point in time, you can look up the contents of the variable
or rewrite the contents of the variable with new stuff. When you do
this, the variable itself doesnt need to change, just the contents in
the box. Each variable has a name and a type. The name is what
youll use in your program when you want to read its contents or
put new stuff in it.
( Source: The C# Players Guide)
Data type: Data types are declarations for memory locations or
variables that determine the characteristics of the data that may be
stored and the methods (operations) of processing that are permitted
involving them. The variables type indicates what kind of
information you can put in it. C has a large assortment of types that
you can use, including a variety of integer types, floating point (real
valued) types, characters and a whole lot more.
(Source: The C# Players Guide)

struct book \\ create a data structure for a


book
{
char bISBN[n]; \\represents the value of the
book id and may contain n
characters

char bTitle[n]; \\represents the value of the


book title and may contain n
characters

int bPuplishedyear; \\represents the value of the


book published year and may
contain n characters

char bPuplisher[n]; \\represents the value of the


book publisher and may
contain n characters

char bAuthors[n]; \\represents the value of the


book id and may contain n
} characters characters

int count; \\ count the number of books in


library

b. Selection structures:
switch...case: a type of selection control mechanism used to
allow the value of a variable or expression to change the control
flow of program execution via a multiway branch. (Wikipedia)
if...else: features of a programming language, which perform
different computations or actions depending on whether a
programmer-specified boolean condition evaluates to true or false.
(Wikipedia)
c. iteration constructs:
for: a control flow statement for specifying iteration, which
allows code to be executedrepeatedly. (Wikipedia)
white: a control flow statement that allows code to be
executed repeatedly based on a condition. (Wikipedia)
d. Modules and functions:
Modules : stdio.h , stdlib.h

Functions: FFlush(stdin): delete buffer


System(cls): clear screen
System(pause): pause program
Scanf(): Receive data from keyboard
Printf(): Print data on the screen
Gets() : Receice data is string from keyboard

2.2 Design a procedural programming solution for a


given problem:
a.Produce use case diagram(s) for the actions required:
ADD NEW BOOK

VIEW ALL BOOKS

SEARCH BOOKS

DELETE BOOKS

UPDATE BOOK

Manager
EXIT

b. Produce flowchart(s) for the program design:


Add new book: void addnewbook(char bISBN,
char bTitle, int bPublishedyear, char bPublisher,
char bAuthors)

START
F

Input book ISBN Check ISBN

T
Input book title

Input book published


year

Input publisher

Input authors

END
View all book: void viewallbook(int i, int n)

START

F
i<n

T
Print information of the book

i++

END
Search book: void searchbook (char bookname, int
i, int n)

START

Input books name;


i=0; n=count;

F
i<n

Check books name F


and bTitle i++

Print books name;


i++

END
START

do
printf:
1. Add new book
2. View all books
3. Search books
4. Delete books
5. Update book
6. Exit

switch(choice)

T
CASE1 addnewbook(...),
count++
F
T
CASE2 Viewallbook(...)

F
T
CASE3 Searchbook(...)

F T F
Print the book to
the screen

Input bookname
again and recheck
T
CASE4 Searchbook(...)
T
F F
Delete the book

Input bookname
again and recheck

T F
CASE5 Searchbook(...)
T Delete the book
F

addnewbook(...)

Input bookname
again and recheck

CASE6 Print bye bye!!!


T
F

Default Print invalid n!!!


T
While
choice!=6

END

S-ar putea să vă placă și