Assignment 1 Front Sheet: Qualification BTEC Level 5 HND Diploma in Computing
Assignment 1 Front Sheet: Qualification BTEC Level 5 HND Diploma in Computing
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
1
Summative Feedback: Resubmission Feedback:
2
A Task 1
I. PROGRAMMING LANGUAGE
1. Programming language
2. Compile
3. Types of language
4.Interpreter
II. MAIN FEATURES OF PROCEDURAL PROGARMMING
B. TASK 2
I. Identify the variables and data types required in the program.
1. Variable Definition
2. Variable Definition
3. Variable Declaration
4. Data type
II. Identify and describe 2 different selection structures
1. 2 control structures:
III. Identify and describe any iteration constructs
1. For loop
2. While loop
3. Do..while loop.
4.Conclude
C. Task 3.
III. Reviewing
D. REFERENCES
3
A Task 1
I. PROGRAMMING LANGUAGE
1. Programming language
A program is a number of commands that can be executed by a computer to be programmed by
The people. The program operates on the commands of programmers to accomplish the purpose of
Which it was created. It is also up to programmers to write code to run the program.
And training its consumers.
The data is obtained by the system and translated into a bit sequence 0 1. The Bit is the
The smallest data to be interpreted on the machine. The language of programming is the language for
programmers to write computer programs. Programming language refers to the degree of high
Tongue, language. C, C++, Ada, Pascal, ... For example , the purpose of these languages is to convert
Human languages are used in languages understood by computers. There are two ways of
converting grogram: Program compilation and program interpretation.
2. Compile
Compile is a program that translates programming-language commands into a programming language In
the form of a programming language and a lower level language, another equivalent program
3. Types of language
Low-level coding languages have a lower abstraction level and are the opposite of high-level languages,
as you might expect. They are similar to the binary language and further from the language of man. Low-
level languages are more difficult to learn and use, but offer more computer functionality and direct
control.
While it can take more time and code lines to do the same as a high-level language, low-level languages
are much less restrictive and allow programmers to produce much more comprehensive and efficient
programming.
The languages of high-level coding have a higher abstraction level. This suggests that they are similar to
the language of humans, and further from machine code. It is easier to learn and use high-level languages,
but they generally offer less functionality and direct control over the computer.
High-level languages tend to be more automated, where many pre-programmed things are actually done
by a single programming command to facilitate and make programming more efficient.
4
(Bunch, 2020)
4.Interpreter
An interpreter is a program that implements instructions written in high level language
5
B. TASK 2
I. Identify the variables and data types required in the program.
A variable is nothing but a name given to a storage area which can be controlled by our programs. Each
variable in C has a particular form that specifies the variable's memory size and layout; the range of values
that can be stored in that memory; and the collection of operations that can be applied to that variable.
A variable name may consist of letters , numbers, and underscores. It has to start either with a letter or
with an underline. There are different upper and lowercase letters because C is case-sensitive. Based on
the basic types explained in the previous chapter, there will be the following basic variable types:
2. Variable Definition
A variable definition tells the compiler where and how much storage to create for the variable. A variable
definition specifies a data type and contains a list of one or more variables of that type. For example:
Int I, j, k;
Char c, ch;
Float f;
Double d;
6
In which The line int i, j, k; declares and defines the variables i, j, and k; which instruct the compiler to
create variables named i, j and k of type int.
3. Variable Declaration
A variable declaration informs the compiler that a variable of the stated type and name exists, so that the
compiler can continue with further compilation without needing full details of the variable. A variable
definition only has its value at the time of compilation, at the time of linking the program, the compiler
requires real variable definition.
4. Data type
Data types in c refer to an extensive system used for declaring variables or functions of different types. The
type of a variable determines how much space it occupies in storage and how the bit pattern stored is
interpreted.
There are 13 types of primitive data types:
- short int
- unsigned short int
- unsigned int
- int
- long int
- unsigned long int
- long long int
- unsigned long long int
- signed char
- unsigned char
- float
- double
- long double
7
MEMORY FORMAT
DATA TYPE (BYTES) RANGE SPECIFIER
-2,147,483,648 to
int 4 2,147,483,647 %d
-2,147,483,648 to
long int 8 2,147,483,647 %ld
unsigned long 0 to
long int 8 18,446,744,073,709,551,615 %llu
float 4 %f
double 8 %lf
With my plan, I will create 4 variables with integer data, 2 variables with float data and 1 with char data.
int x,y,z, choice;
float max,min;
char name[N]
I will enter multiple variables with two data types: int and float and the max and min variables store the
values as real numbers
8
II. Identify and describe 2 different selection structures
1. 2 control structures:
Algorithm: A problem solving technique with regard to the actions to execute the order in which will
perform the actions
Pseudocode:" fake "code for" fake "code, describing the action status in English lets a programmer "think
out" the issue and "think out" the problem.Alternative but does not execute.
Control / Execution Flow: implemented with three simple basics Structure forms.
Sequential: default mode; Line by line, one right after the other, executed.
When there are two or more alternatives. Three types:
If
if...else
printf("Tgian: \n");
scanf("%f", &tgin[i]);
}
current += k;
system("cls");
}else{
9
printf("\chi co the luu tru nhieu nhat %d nhan vien.\n\n", N);
}
Switch
Example for Switch case:
1. switch(choice){
2. case 1:
3. printf("ban chon lua chon 1!!!\n");
4. break;
5. case 2:
6. printf("ban chon lua chon 2 !!!\n");
7. break;
8. case 3:
9. printf("ban chon lua chon 3 !!!\n");
10. break;
11. case 4:
12. printf("ban chon lua chon 4 !!!\n");
13. break;
14. case 5:
15. printf("ban da thoat chuong trinh\n");
16. printf("Tam biet.\n");
17. break;
18. default:
19. printf("khong co lua chon %d. ", choice);
20. printf("Hay nhap lai\n");
21. break;
10
22. }
Repetition: used for looping, or repeating a section of code multiple times. Three types:
while
do...while
for
True and False: Statements that are executed are dependent on certain conditions that are evaluated either
true or false. Condition represented by logical (Boolean) expression - can be true or false. An expression
that evaluates to 0 is false. An expression that evaluates to a non-zero value is true
b. Relational operator
Relational operators: Allow comparisons, require two operands (binary). Return 1 (or nonzero integer) if
expression true, otherwise 0 false. Comparing values of different data types may produce unpredictable
results For example: 6 < '5' (compares integer 6 with character '5')
= = equal to
x == y
!= not equal to
x != y
< less than
x<y
<= less than or equal to
x <= y
> greater than
x>y
>= greater than or equal to
x >= y
***BE CAREFUL!***
11
I will use the Switch case to split Menu requests into multiple options. Allows users to select the required
requirements.
1. For loop
“This statement is used to repeat a statement or a set of statements for a specified number of times or
until a condition satisfied.”
(Cognizant, Handout: Problem Solving, 2007)
https://www.programiz.com/c-programming/c-for-loop )
12
Then, the test expression is evaluated. If the test expression is evaluated to false, the for loop is
terminated.
However, if the test expression is evaluated to true, statements inside the body of for loop are executed,
and the update expression is updated.
Again the test expression is evaluated.
This process goes on until the test expression is false. When the test expression is false, the loop
terminates.
int main() {
int i;
Output
1 2 3 4 5 6 7 8 9 10
I is initialized to 1.
The test expression i < 11 is evaluated. Since 1 less than 11 is true, the body of for loop is
executed. This will print the 1 (value of i) on the screen.
The update statement++i is executed. Now, the value of i will be 2. Again, the test expression is
evaluated to true, and the body of for loop is executed. This will print 2 (value ofi) on the screen.
Again, the update statement ++i is executed and the test expression i < 11 is evaluated. This
process goes on until i becomes 11.
When i becomes 11, i < 11 will be false, and the for loop terminates.
13
Example 2: for loop
return 0;
}
The value entered by the user is stored in the variable num. Suppose, the user entered 10.
14
The count is initialized to 1 and the test expression is evaluated. Since the test expression count<=num
(1 less than or equal to 10) is true, the body of for loop is executed and the value of sum will equal
to 1.
Then, the update statement ++count is executed and the count will equal to 2. Again, the test expression
is evaluated. Since 2 is also less than 10, the test expression is evaluated to true and the body of for loop
is executed. Now, the sum will equal 3.
This process goes on and the sum is calculated until the count reaches 11.
When the count is 11, the test expression is evaluated to 0 (false), and the loop terminates.
https://www.programiz.com/c-programming/c-for-loop )
2. While loop
“In most computer programming languages, awhile loop is a control flow statment that allows
code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of
as a repeating if statement .”
(2020, While loop, http://en.wikipedia.org/ , https://en.wikipedia.org/wiki/While_loop )
15
(Flow Diagram of while loop,C - while loop in C programming with example,
http://beginnersbook.com/ , https://beginnersbook.com/2014/01/c-while-loop/ ) “Example of while
loop:
#include <stdio.h>
int main() {
int count=1;
while (count <= 4)
{
printf("%d ", count); count++;
}
return 0;
}
Step1: The variable count is initialized with value 1 and then it has been tested for the condition.
Step2: If the condition returns true then the statements inside the body of while loop are executed else
control comes out of the loop.
16
Step3: The value of count is incremented using ++ operator then it has been tested again for the loop
condition. ”
3. Do..while loop.
“A do while loop is similar to while loop with one exception that it executes the statements inside the
body of do-while before checking the condition.”
(Flow Diagram do-while loop, C/C++ do while loop with Examples – GeeksforGeeks, GeeksforGeeks,
https://www.geeksforgeeks.org/c-c-do-while-loop-with-examples/ )
17
#include <stdio.h> int main()
{
int j=0; do
{
printf("Value of variable j is: %d\n", j);
j++;
} while (j<=3);
return 0; }
Output:
4.Conclude.
In my program, I use the do ... while loop in the body of the program. Purpose of creating the menu. If
the user selects a digit outside the program menu. The program will execute the loop.
1. Modules
A function definition in C programming consists of a function header and a function body. Here are all
the parts of a function
Return Type − A function may return a value. The return_type is the data type of the value the function
returns. Some functions perform the desired operations without returning a value. In this case, the
return_type is the keyword void.
18
Function Name − This is the actual name of the function. The function name and the parameter list
together constitute the function signature.
Parameters − A parameter is like a placeholder. When a function is invoked, you pass a value to the
parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type,
order, and number of the parameters of a function. Parameters are optional; that is, a function may
contain no parameters.
Function Body − The function body contains a collection of statements that define what the function
does.
C. Task 3.
Menu
19
(Flow chart diagram for main menu)
I will use the while loop and switch case so that the user can use the menu. they can select other menu
functions after they complete the function. If you select 1 to 5, the program may repeat. The option
number 6 is for the user to exit the program.
20
Flow chart diagrams for primary functions.
-- All employee IDs and their working hours must be printed. Both elements of the array ID must be
printed with the elements of the corresponding array marker.
-- With the for loop, to do this.
-- First of all, we test the variable with n. Print I d and label at position 0 if correct, then increase the count
variable to 1 and begin the loop. If the mistake has not been repeated and the loop exits,
III. Reviewing
21
I will use the while loop and the case for switching so that the menu can be used by the user. Upon
completion of the feature, they can select other menu functions. If you choose 1 to 5, it is possible to
repeat the program. The number 6 alternative is for the user to exit the software.
With the mark [n] and I d [n] arrays available. All IDs can be printed with employee accents.
-- All employee IDs and their working hours must be printed. Both elements of the array ID must be
printed with the elements of the corresponding array marker.
-- With the for loop, to do this.
-- First of all, we evaluate the variable with n. Print I d and label at position 0 if correct, then increase the
count variable to 1 and begin the loop. If the mistake hasn't been repeated, exit the loop. In order to find
the average value of the working time of that business, I will use the AVG function. The user will then
know who is working hard and who is not working hard.
22
D. REFERENCES:
Bunch, G., 2020. Types Of Coding Languages Guide | Career Karma. [online] Career Karma. Available at:
<https://careerkarma.com/blog/types-of-coding-languages/#highlevel-programming-languages> [Accessed 15
October 2020].
Learnprogramo. 2020. Types Of Programming Language [ With Explanation ] - Learnprogramo. [online] Available
at: <https://learnprogramo.com/types-of-programming-language-5/> [Accessed 15 October 2020].
Hackr.io. 2020. What Is Procedural Programming? [Definition] - Key Features. [online] Available at:
<https://hackr.io/blog/procedural-programming> [Accessed 15 October 2020].
23