Docsity

Procedural Programming Assignment, Thesis of Banking and Finance

Partial preview of the text

Download Procedural Programming Assignment and more Thesis Banking and Finance in PDF only on Docsity!

Higher Nationals in Computing

Unit 0: Procedural Programming

ASSIGNMENT 1 Learner’s name: Lê Thái Trung Tín ID: GCS Class: GCS1005A Subject code: PROG Assessor name: PHAN MINH TAM Assignment due: Assignment submitted:

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 0: IT Fundamental & Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Lê Thái Trung Tín Student ID GCS Class GCS1005A Assessor name Phan Minh Tam 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 D

ASSIGNMENT 1 BRIEF

Unit Number and Title Unit 0: IT Fundamental & Procedural Programming Academic Year 2022 Unit Tutor Assignment Title Assignment 1: Analysis and Design a solution for procedural programming problem Issue Date Submission Date IV Name & Date Learning Outcomes and Assessment Criteria Pass Merit Distinction LO1 Understand the principles of procedural programming LO2 Be able to design procedural programming solutions P1 Provide an introduction to procedural programming M1 Discuss on characteristics and features of procedural programming D1 Critically evaluate the design of your solution against the characteristics and features of procedural programming. P2 Identify the program units and data and file structures required to implement a given design M2 Review the design of a procedural programming solution. P3. Design a procedural programming solution for a given problem Assignment Brief Scenario: A math teacher wants to manage grades of a class. He asks 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 be menu based with the 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.

Task 1 To prove your programming ability to be appointed to this small project, please prepare an illustrated guide on programming in general and a particular emphasis on procedural programming. Here you will need to include introduction to computer programming languages and discuss key features of procedural programming. Task 2 Your next task is to do the analysis for the scenario mentioned above by doing the following subtasks

  • Identify the variables and data types required in the program.
  • Identify and describe 2 different selection structures, including the condition(s) to check; state why they are needed and where they can be used in the context of the scenario.
  • Identify and describe any iteration constructs.
  • Split the program into functions (sub-functions) and draw a hierarchy diagram to illustrate the structure of your program. Task 3 You need to use a drawing tool to draw design diagram for your program, includes:
  • A use case diagram for actions required
  • Flow chart diagrams for: menu operation, printing IDs and grades, finding max grade and finding min grade.
  • Review / evaluate your design, state clearly pros vs cons and which needs to improve, using characteristics of procedural programming as bases to discuss. Write a report for 3 tasks above and submit the report to CMS in PDF format. Submission Format The submission is in the form of an individual written report. This should be written in a concise, formal business style using single spacing and font size 12. You are required to make use of headings, paragraphs and subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing system. Please also provide a bibliography using the Harvard referencing system.

ASSIGNMENT 1 ANSWERS

P1 Provide an introduction to procedural programming

1. Introduction to computer programming languages 1.1 Definition A programming language is a formal language consisting of a set of instructions that produce various types of output. Programming languages are used in computer programming to implement algorithms. Most programming languages include commands for computers. 1.2 High level programming A high leve language is a programming language that is meant to make computer programming easier. The term ”high level” refers to the separation of the numerous processor operations from the actual application. 1.3 Low level programming A low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture—commands or functions in the language map that are structurally similar to processor's instructions. Generally, this refers to either machine code or assembly language. 2 Introduction to procedural program 2.1. Definition Procedural Programming can be defined as a programming model which is derived from structured programming, based upon the concept of calling procedure. Procedures, also known as routines, subroutines or functions, simply consist of a series of computational steps

to be carried out. 2.2. Introduction to C Programming Language C is a high-level, general-purpose programming language that's perfect for creating firmware and portable apps. Dennis Ritchie created C for the Unix Operating System in the early 1970s at Bell Labs, with the intention of creating system software.

3. Criteria to select a programming language to use Factors to Consider There are several factors to consider when choosing a web programming language. Say, for example, in developing a dynamic web page, one might consider Java Server Pages (JSP) as the best option, while another might consider using PHP or a similar scripting language. No single language is the best choice for any given project. Although preference might be given to certain factors like performance, security in enterprise applications, fewer lines of code among other factors. For personal projects, the selection of a programming language may be as simple as picking a personal favorite. Here the brevity of the lines of code is important. The fewer the lines necessary to develop the project, the better. The idea is to get the solution out first, then worry about the neatness or performance later. However, for large organizational projects, things are different. Different developer teams are going to build components that are meant to interact and interconnect with each other to solve a particular problem. In this case, the choice of language might involve the ease of portability of the program to different platforms or the availability of resources.

making a decision to adopt the considered language(s). The Time to Production This is the time taken to make the program go live, when the code is production-ready and works as intended. It is highly dependent on the size of code. In theory, the easier it is to learn a language, the smaller the code and thus less time taken to go live. Take for example, in development of a content management website, it is possible to take days using PHP development scripts while the use of servlets code can take months. This is going by the assumption that you are learning both languages from scratch. Performance Only so much of performance can be squeezed out of a program and a platform, with the programming language used in the program development affecting performance. Numerous studies have been conducted comparing how fast programming languages are in the same environment. This has led to the development of various benchmarks which can be used as a reference. The figures however are not for concrete assessment of the performance of any language. Language performance should matter when the target environment doesn’t offer much scope for scaling. A good example of such an environment are handheld devices. Support and Community Programming languages and good software are similar in that they both need a community following to help them grow. Languages with active forums are likely to be more popular than even greater languages without similar forums. Some of the offerings of community support include wikis, forums, tutorials and most importantly additional libraries, all of which help the language to grow. Other Factors to Consider Purpose What is the objective of the programming language? It specifies the objective for which a program is being developed. In the event that one needs to develop commercial applications, then a business oriented programming language like COBOL is the best candidate. For development of scientific applications, it is best to use a scientific oriented language like FORTRAN.

Similarly, if one is interested in developing programs related to Artificial Intelligence, then he or she should be comfortable using the LISP or ProLog languages. Object oriented languages are best suited for development of web-based applications. As for the development of system programs, a middle level language like C should be chosen. Programmer Experience Where more than one programming language is available for the development of the same program, a programmer should choose the language he is more conversant with. Generally, one should go for the language for which he is more experienced. Ease of Development and Maintenance Programmers develop programs using the language they are most comfortable in. Generally, there is a preference for object-oriented languages over the procedural oriented languages. The reason for this is that, code developed in object-oriented languages can be reused and maintained with great ease. Efficiency Efficiency is an important factor which need be considered before choosing a programming language for software development. One should consider the language in which the programs can be developed and executed rapidly. Additionally, the language which requires less amount of memory for the storage of programs should be selected. Availability of an IDE A powerful Integrated Development Environment goes a long way in increasing the productivity of a programmer. The language with an IDE of well supported development, debugging and compilation tools should be selected. Error Checking and Diagnosis These factors involve finding the errors in a program and their causes. Programmers should choose programming languages which contain efficient error handling features. Error checking and diagnosis is very important and crucial in the development of quality and error-free programs. The task of code development and testing is easier when undertaken with a programming language with efficient and robust error detection and correction mechanisms.

  • //{C is a strongly typed language. This means that the variable type cannot be changed once it is declared. For example:
  • int number = 5 ; // integer variable
  • number = 5.5; // error
  • double number; // error Here, the type of number variable is int. You cannot assign a floating-point (decimal) value 5.5 to this variable. Also, you cannot redefine the data type of the variable to double. By the way, to store the decimal values in C, you need to declare its type to either double or float.}; 2. Datatypes 2.1. Definition
  • C data types are defined as the data storage format that a variable can store a data to perform a specific operation.
  • C divides the data into different groups which is the data type.

2.2. Types of data types in C Int : for storing Student’s ID. Instead of using other data for this solution, integer is the best option because I just want to be familiar with best practices and standard coding conventions. Char : for storing Student’s Name. Float or Double : for storing Student’s Grade. Using this data for storing grades because float or double, for the exactly decimal number of the grade And I will be using ARRAY for storing multiple values in a single variable such as the id, the name and the grades of the students. 3. Selection structures (Conditional Statements)

  • Alternatively known as a conditional expression, conditional flow statement, and conditional processing, a conditional statement is a set of rules performed if a certain condition is met. It is sometimes referred to as an If-Then statement, because IF a condition is met, THEN an action is performed. 3.1. If statement The IF statement is a decision-making statement that guides a program to make decisions based on specified criteria. The IF statement executes one set of code if a specified condition is met (TRUE) or another set of code evaluates to FALSE. 3.1.1. Syntax

conditionals perform different computations or actions depending on whether a programmer- defined condition evaluates to true or false. If-else Structures use to test in certain condition and make decision about which code block need to be executed. If-else Structures to find the student have lowest grade the same with student have highest grade with the condition is : the student in the current loop have grade lower than the grade of student in the previous loop, then returns the student with the lower grade in current loop. 3.2.1 Syntax if (test expression) {…//code} else {… // code} 3.2.2 Example 1.#include<stdio.h> 2.int main(){ 3.int number=0; 4.printf("enter a number:"); 5.scanf("%d",&number); 6.if(number%2==0){ 7.printf("%d is even number",number); 8.} 9.else{ 10.printf("%d is odd number",number); 11.} 12.return 0; 13.} 3.3 If...else if The if...else statement is used to execute a block of code among two alternatives. However, if we need to make a choice between more than two alternatives, we use the if...else if...else statement. The syntax of the if...else if...else statement is: 3.3.1 Syntax

if (condition1) { // block of code to be executed if condition1 is true } else if (condition2) { // block of code to be executed if the condition1 is false and condition2 is true } else { // block of code to be executed if the condition1 is false and condition2 is false } 3.3.2 Example int time = 22; if (time < 10) { printf("Good morning."); } else if (time < 20) { printf("Good day."); } else { printf("Good evening."); } // Outputs "Good evening." 3.4 Switch...case

  • Switch-case structures use to design a menu options for user to help them determined what functionin program they want to use. The switch case is used when we have multiple options and we want to compared the input value with all the cases inside the switch..case block to execute different options. true. 3.4.1 Syntax switch (expression) { case constant1: // statements break; case constant2: // statements break; .

4.1 For statement The For Loop is a loop where the program tells the compiler to run a specific code FOR a specified number of times.This loop allows using three statements, first is the counter initialization, next is the condition to check it and then there is an increment/decrement operation to change the counter variable. You will understand it once we see some programs .1.1 Syntax for (expression1; expression2; expression3) { //statements } 4.1.2 Example 4.2 While statement

. - A while loop in C programming repeatedly executes a target statement as long as a given condition is 4.2.1. Syntax while (condition) { statements; }

4.2.2. Example 4.3. Do…While The do-while loop in C is very closely related to the while loop. The do keyword is placed on a line of code at the top of the loop. A block of statements follows it with a test expression after the keyword while, at the bottom of the loop. It is a post-test loop. The post-test loop executes at least, only then control expression is tested. If the expression is true, the loop repeats. When the expression is false then the loop terminates. 4.3.1. Syntax 4.3.2. Example