0% found this document useful (0 votes)
84 views16 pages

Programming Asm1 Nguyengioi

The document provides instructions for an assignment to demonstrate problem solving and basic programming skills for a software development job interview. It asks the applicant to explain how algorithms can solve simple business problems, and to analyze a problem, design a flowchart, and program a solution in modules using basic programming constructs like input/output, assignment statements, loops and conditionals. The applicant chooses to create a program that finds the largest and smallest number in an array, and provides an analysis of the problem and examples of algorithms to solve it.

Uploaded by

Nguyễn Giỏi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views16 pages

Programming Asm1 Nguyengioi

The document provides instructions for an assignment to demonstrate problem solving and basic programming skills for a software development job interview. It asks the applicant to explain how algorithms can solve simple business problems, and to analyze a problem, design a flowchart, and program a solution in modules using basic programming constructs like input/output, assignment statements, loops and conditionals. The applicant chooses to create a program that finds the largest and smallest number in an array, and provides an analysis of the problem and examples of algorithms to solve it.

Uploaded by

Nguyễn Giỏi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 1: Programming

Submission date 24/08/2021 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Nguyen Gioi Student ID GCD210284

Class GCD0904 Assessor name Hoang Nhu Vinh

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 Gioi

Grading grid

P1 M1 D1
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:
Table of contents :
I.Scenario :..................................................................................................................................................................... 3
II. Algorithms and problems. (P1) ................................................................................................................................. 4
1.Algorithm : ............................................................................................................................................................. 4
1.2 Algorithm features:.......................................................................................................................................... 5
1.3 Example : ......................................................................................................................................................... 5
2. Problem : ............................................................................................................................................................... 6
III. Problem analysis and flowchart. (P1) ...................................................................................................................... 6
1.Problem analysis : .................................................................................................................................................. 6
2.Flowchart :.............................................................................................................................................................. 7
IV. Program and program explanation: (P1 and M1) .................................................................................................. 10
1.Program : .............................................................................................................................................................. 10
2 Explanation of source code compilation: ......................................................................................................... 11
3. Program results: ................................................................................................................................................... 13
4. Test case and test result : ..................................................................................................................................... 13
5. Program development lifecycle: .......................................................................................................................... 14

Figure 1 : Scenario ......................................................................................................................................................... 3


Figure 2: What is the algorithms ? ................................................................................................................................ 4
Figure 3 : Flowchart 1 .................................................................................................................................................... 7
Figure 4: Flowchart 2 ..................................................................................................................................................... 8
Figure 5 : Flowchart 3 .................................................................................................................................................... 9
Figure 6 : Program 1 .................................................................................................................................................... 10
Figure 7 : Program 2 .................................................................................................................................................... 11
Figure 8: Explanation of source code compilation ...................................................................................................... 11
Figure 9 : Explanation of source code compilation ..................................................................................................... 12
Figure 10 : Explanation of source code compilation ................................................................................................... 12
Figure 11 : Program results ......................................................................................................................................... 13
I.Scenario :
You have applied for a post as a trainee with a software development company and have been invited for
an interview. You have been asked to demonstrate your problem solving and basic programming skills. To
do this you have to prepare a report on using algorithms to solve problems.

You need to explain, using examples, how algorithms are used to solve simple business problems and
the steps needed to be followed to produce a working program solution. You should make clear your
assumption about your program. The problems to be solved will involve basic procedural programming
instructions - sequence instructions (input, output and assignment statements), loops, conditional
statements. Problems should be analysed and designed by the use of flowchart and demonstrated by the
use of modules (procedures).

Figure 1 : Scenario
II. Algorithms and problems. (P1)

1.Algorithm :
Algorithm or algorithm has many complicated definitions. You can read in many sources to understand
more about it. Personally, I define it as easy to understand that an algorithm is an "algorithm" (method) to
solve a problem. To make it easier to understand, each problem is like a treasure chest (results, answers),
and the key to open that box is the "algorithm". If you use the wrong key, you can still open the box, but it
will take a long time, or if you can open the box, the treasure inside is distorted and incomplete. Using the
right key will help you get the treasure easily and quickly. Of course, each box will always need a
different key, just like a problem always has a definite algorithm. There is no single key that can open all
the chests, just as there is no algorithm that can solve all the problems.

Figure 2: What is the algorithms ?

Why use algorithms?


Programming is to request, instruct the machine to perform, to solve a specific task or problem in life.
Each real problem will have a different solution. Understanding and using the right algorithm will help
you solve it easily, with high accuracy in the shortest time.
1.2 Algorithm features:
Unambiguous – The algorithm must be clear and unambiguous. Each of its steps (or stages), and their
inputs/outputs should be clear and lead to only one meaning.

Inputs – An algorithm must have zero or more well-defined inputs.

Output – An algorithm must have one or more well-defined outputs and must match the desired output.

Finiteness – The algorithm must terminate after a finite number of steps.

Feasibility – Must be feasible with available resources (resources, existing equipment).

Independent – An algorithm should have step-by-step instructions, which should be independent of any
programming code.

1.3 Example :
Design an algorithm to add two numbers and display the result.

Method description 1:

Step 1 – GETTING STARTED

Step 2 – declare three integers a, b & c

Step 3 – determine the values of a & b

Step 4 – add the values of a & b

Step 5 – store the output of step 4 to c

Step 6 – print c

Step 7 – STOP

Method description 2:

Step 1 – START ADDING CODE

Step 2 – get the values of a & b

Step 3 – c a + b

Step 4 – display c

Step 5 – STOP
In the design and analysis of algorithms, often the second method is used to describe an algorithm. It
makes it easy for the analyst to analyze the algorithm ignoring all unwanted definitions.

2. Problem :
To implement the company's scenario. I will create a simple program that finds the largest and smallest
element in an array. The reason I created the program is because it will include all the requirements that
the problem gives including output, input, statements, conditionals and loops.

I will use Sharp C language to solve my program and algorithms. I think this program is quite good and
interesting, it will help me and my friends synthesize the knowledge when learning C Sharp.

III. Problem analysis and flowchart. (P1)

1.Problem analysis :
Like the problem I mentioned above, I am going to create a program that finds the largest and smallest
number in an array. It will take an integer n as input. The output will have a smallest number and a
maximum number. I will integrate loops and conditions into the program so that it is complete and suitable
for the scenario. I will clarify in the flowchart section.
2.Flowchart :

Figure 3 : Flowchart 1
Figure 4: Flowchart 2
Figure 5 : Flowchart 3

To display the largest and smallest number in the array, we will pass the following conditions:
(Flowchart)

Step 1: We will enter an array n from 1 to 100. If input is 0 or any other character, the program will
immediately stop and automatically set the maximum and minimum values to 0 or the program error will
occur automatically.

Step 2: When finished entering n arrays, the program will create a for loop. Example: If you enter the
array number as 5, the program will repeat 5 times for you to complete the array number. If in those 5
arrays there is an array containing characters, the program will report an error and exit.

Step 3: The program will check the arrays and find out the largest and smallest number in the array that
we entered. Finally, display the found results on the screen.
IV. Program and program explanation: (P1 and M1)

1.Program :
As I introduced at the beginning, I will use C Sharp language to create a program and solve algorithms.

Figure 6 : Program 1
Figure 7 : Program 2

2. Explanation of source code compilation:

Figure 8: Explanation of source code compilation

First I will initialize the array and choose an integer data type and limit the array to 100 values.

Convert.ToInt32 helps us to convert data type to integer.

Next, I will create a loop and give the value i equal to 0, give the array value n greater than i , if less than
or equal then the program will terminate automatically.

Next :
Figure 9 : Explanation of source code compilation

Next we will find the largest smallest value in the array. We will have two values mx and mn, we will give
these two values starting from 0 because the index of the array always starts at 0.

Next we will create a loop (i = 1; i < n; i++)

If the value of mx is less than arr1[i] then it will update the value of mx with arr1[i]. Similarly, if the value
of mn is greater than arr1[i], it will update the value of mn with arr1[i].

Final:

Figure 10 : Explanation of source code compilation

We conclude and print the largest and smallest numbers to the screen.
3. Program results:

Figure 11 : Program results

4. Test case and test result :


Test Test Input Test result Conclusion
case objective data
1 Find the N=5 Pass
largest N=6
and N=9
smallest
number.
2 Find the N=0 Fail, When the value
largest 0 is entered, the
and program will end
smallest automatically.
number.

3 Find the N=w Fail, When entering


largest any character, the
and program will report
smallest an error and cannot
number. execute the program.

5. Program development lifecycle:


Because this is a simple program, its development life cycle is very fast. Initially I will create for myself
the problem of finding the largest and smallest number in the array. After having the problem, I started to
come up with ideas to solve it and what algorithms to use. To simplify the problem, I drew a diagram to
help me better visualize the problem and start solving from which step. After getting the idea and the
solution, I started writing and running the program. The program has run successfully. The program has
included the characteristics of the algorithm as input and output data, obviously.
References Lists :
Available at : https://codelearn.io/sharing/thuat-toan-la-gi-hoc-thuat-toan-lam-quai-gi

Available at : https://cafedev.vn/tim-hieu-chi-tiet-ve-dac-diem-va-cac-thuat-ngu-lien-quan-toi-thuat-
toanalgorithms/

You might also like