0% found this document useful (0 votes)
5 views3 pages

Programming

The document outlines the programming concepts including arithmetic, logical, and boolean operations, and details the program development cycle consisting of analysis, design, coding, and testing. It explains the importance of storing accepted passwords in a file for retrieval and non-volatile storage, and provides pseudocode for bubble sort and linear search algorithms. Additionally, it emphasizes best practices for writing maintainable code, such as using comments, meaningful identifiers, and proper formatting.

Uploaded by

Huzaifa Zaheer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Programming

The document outlines the programming concepts including arithmetic, logical, and boolean operations, and details the program development cycle consisting of analysis, design, coding, and testing. It explains the importance of storing accepted passwords in a file for retrieval and non-volatile storage, and provides pseudocode for bubble sort and linear search algorithms. Additionally, it emphasizes best practices for writing maintainable code, such as using comments, meaningful identifiers, and proper formatting.

Uploaded by

Huzaifa Zaheer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming

AITHEMATIC: +, -, DIV, MOD

LOGICAL: >=, <=

BOOLEAN: AND, NOR, OR

PROGRAM DEVELOPMENT CYCLE

1. Analysis
2. Design: construction of program using standard methods
3. Coding: program is written and iterative testing is done.
4. Testing: program is tested for errors and whether it meets the requirements.

ANALYSIS

1. Abstraction: Discarding irrelevant information and keeping key elements of the problem.
2. Decomposition: Breaking down the program into inputs, processes, outputs and storage.
3. Identification of the problem: Identification of the requirements of the solution to the problem.
4. Research into the problem by data collection such as doing surveys

DESIGN

1. Structure Diagram: A hierarchical diagram showing the breakdown of a computer program into
sub-programs
2. Flowchart: A diagram showing the ordered steps to complete a computer program
3. Pseudocode: shows what a program does in plain language

WRITING in a file

OPENFILE MyPassword.txt FOR WRITE

WRITEFILE MyPassword.txt, Password

CLOSEFILE MyPassword.txt

Explain why the accepted password needs to be stored in a file.

1. needs to be retrieved on demand // saved for a later date


2. storage must be non-volatile

TEST DATA

1. Normal: within the range


2. Abnormal: incorrect format/ out of range
3. Extreme: Least and Highest acceptable value
4. Boundary: 1 value is accepted while the other is rejected.

BUBBLE SORT
Write an algorithm in pseudocode to sort the array Values[1:50] into ascending order using a bubble
sort.

Last  50

Repeat

Swap  FALSE

FOR Index  1 TO Last - 1

IF Values[Index] > Values[Index + 1]

THEN

Temp  Values[Index]

Values[Index]  Values[Index + 1]

Values[Index + 1]  Temp

Swap  TRUE

ENDIF

NEXT

Last  Last – 1

UNTIL NOT Swap or Last = 1

LINEAR SEARCH

A linear search and a bubble sort are standard methods of solution. Fifty numbers are already stored in
the array Values[1:50]

Write an algorithm in pseudocode to input a number, MyNumber, and use a linear search to test if that
number is stored in the array. If the number is found in the array, the position in the array is output. If
the number is not found in the array, “Not found” is output

INPUT MyNumber

Location = 0

FOR Index = 1 TO 50

IF Values[Index] = MyNumber

THEN

Location  Index

ENDIF
NEXT Index

IF Location = 0

THEN

OUTPUT "Not found"

ELSE

OUTPUT Location

ENDIF

ITERATIONS

1. count controlled: number of iterations is pre-determined


2. pre-condition: checks condition at start of loop // loop may not iterate
3. post-condition: checks condition at end of loop // loop always iterates at least once

Explain how the program can be written to make sure it can be easily maintained by the other
programmer.

1. use comments to explain the purpose of each section of code


2. Use meaningful identifier names of variables, constants, arrays, procedures etc.
3. clearly identify the purpose
4. use procedures and functions to avoid repetition
5. use indentation and white space to make the program readable

You might also like