Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 19

Input, Output, and Documenting

Algorithms

Pre-assessment Questions

1. State whether True or False: A


variable is the name of a storage location in the computer memory.

2. Where is the value of a variable stored?

3. What do you mean by declaration of variables?

4. Which operator do you use to compare the values of two operands?

5. What are () operators?

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 1 of 19


Input, Output, and Documenting
Algorithms

Solutions to Pre-assessment Questions

Answer 1: True

Answer 2: The value of a variable is stored in the computer’s internal memory, RAM.

Answer 3: When you declare a variable, a defined memory location is allocated to the
variable. The declaration of a variable assigns a name to the
variable and specifies the type of data stored by the variable.

Answer 5:Relational operator

Answer 5: The order of precedence can be changed using the parenthesis “()” operator.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 2 of 19


Input, Output, and Documenting
Algorithms

Objectives

In this lesson, you will learn about:


• Representing input instructions
• Identifying modes of accepting input
• Representing output instructions
• Identifying modes of generating output
• Using dry run to test the logic of an algorithm
• Documenting an algorithm

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 3 of 19


Input, Output, and Documenting
Algorithms

Introducing Input
• Input is the data that is provided to a computer for processing and generating the
output.

• To receive accurate results from a process, you need to provide the correct input.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 4 of 19


Input, Output, and Documenting
Algorithms

Representing Input

• The input provided to a computer for processing can be represented in several


ways.

• Flowcharts and pseudocode have different methods of representing instruction of


accepting an input .

• Some examples specifying the representation of input are given below:


• In a flowchart, input is represented using the input symbol.
• A pseudocode accepts the input using the accept keyword.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 5 of 19


Input, Output, and Documenting
Algorithms

Modes of Accepting Input


• The way in which you provide any input to the computer depends upon the mode of
interface that a computer uses.
• There are two types of interfaces, Character User Interface (CUI) and Graphical
User Interface (GUI).
• In CUI, a user types commands through a keyboard to perform operations.
• In GUI, a user can use graphical elements, such as menus, buttons, and drop-down
boxes, to perform operations.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 6 of 19


Input, Output, and Documenting
Algorithms

Examples of Input Devices


• A computer receives input from a user with the help of various devices. Some of
the input devices of a computer are:
• Keyboard
• Mouse
• Touch Screen
• Light Pen
• Joy Stick

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 7 of 19


Input, Output, and Documenting
Algorithms

Introducing Output
• A computer requires input to generate the output.

• After accepting the input, the computer processes it and displays the result. This
result is called the output.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 8 of 19


Input, Output, and Documenting
Algorithms

Representing Output
• There are different ways of representing the output in an algorithm. Some
examples specifying the representation of output are given below:
• In a flowchart, output is represented using the display symbol.
• In pseudocode, the output is represented using a keyword, display.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 9 of 19


Input, Output, and Documenting
Algorithms

Modes of Displaying the Output


• Similar to the input, the output displayed also depends upon the modes of
displaying the output, such as a CUI or a GUI.

• In a CUI, the output is displayed in the form of a text.


• In a GUI, the output is displayed in the form of graphic components such as a
Window.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 10 of 19


Input, Output, and Documenting
Algorithms

Examples of Output Devices


• A computer generates the output according to the interface applied by the user
using various devices, such as:
• Printer
• Visual Display Unit (VDU) or Monitor
• Speaker

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 11 of 19


Input, Output, and Documenting
Algorithms

Using Dry Run


• In some cases, the algorithm may have complex logic. These complex conditions
might make it difficult for you to test the logic of the algorithm for correction.

• The dry run


• Will help you perform a logic check and understand the flow of control in an
algorithm.
• With its table provides a step by step evaluation of values in the variables of
the program.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 12 of 19


Input, Output, and Documenting
Algorithms

Documenting an Algorithm
• Documentation is the process of maintaining a record of all the algorithms that are
created during problem solving.

• Proper documentation of algorithms is important because of the following reasons:


• It helps the team members to understand the process and the correct
sequence of the algorithms used to solve a problem.
• A well-maintained document can be modified easily at any time.
• Documentation helps in problem solving in other similar processes.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 13 of 19


Input, Output, and Documenting
Algorithms

Comments in an Algorithm
• Comments are used in an algorithm as a reference to explain the logic of the
algorithm.

• The comments included in an algorithm should enable a user to easily understand


the task performed by each block without going through each line of the algorithm.

• A processor does not translate comments.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 14 of 19


Input, Output, and Documenting
Algorithms

Guidelines for Documenting an


Algorithm
• Some guidelines that need to be followed when documenting an algorithm are as
follows:
• The name of the programmer who developed the algorithm should be
documented.
• The desired output to be generated from the algorithm should be clearly
mentioned in the document.
• The complex statements of the algorithm should be explained using comments.
• All the algorithms in the document should follow a consistent naming convention
for the variables, functions, and procedures used.
• Test cases, also known as sample values, should be provided to dry run each
algorithm in the document.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 15 of 19


Input, Output, and Documenting
Algorithms

Standards of Documentation
• Certain documentation standards should be strictly followed with details to ensure
consistency in the documentation process.

• These documentation standards are as follows:


• All programmers writing an algorithm should consistently follow the naming
conventions used for variables.
• The level up to which comments are to be used in algorithms should be
standardized.
• Programmers should standardize before writing an algorithm whether they
would be using flowcharts or pseudocode for representing algorithms.
• The levels of flowcharts to be created should be decided.
• Programmers should standardize the number of test cases to be used to dry
run each algorithm.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 16 of 19


Input, Output, and Documenting
Algorithms

Advantages of Documentation
Standards
• Documentation standards are important for completing the documentation process
successfully due to the following reasons:
• They help to determine whether or not all the requirements have been met.
• They ensure that the same format and style is followed throughout a
document.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 17 of 19


Input, Output, and Documenting
Algorithms

Summary
In this lesson, you learned:

• Input is the data that is provided to a computer for processing.


• Input can be represented in different ways:
• In pseudocode, the input is represented using the keyword, accept.
• In a flowchart, input is represented using the input symbol.
• Some of the input devices of a computer are a keyboard, a mouse, a touch
screen, a light pen, and a joystick.
• The output is the result of processing input data and displaying the processed
data.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 18 of 19


Input, Output, and Documenting
Algorithms

Summary (Contd.)
• Output can be represented in different ways:
• In pseudocode, the output is represented using the keyword, display.
• In a flowchart, the output is represented using the display symbol.
• Some of the output devices of a computer are a printer, a VDU, and a speaker.
• The dry run helps you to evaluate the output of a program with a set of sample
values.
• Documentation is the process of maintaining a record of all the algorithms created
during the process of problem solving.
• Comments should be used to explain the logic of each block in an algorithm.
Comments are not translated by a processor but are only used for reference.
• Certain documentation standards should be strictly followed with details to ensure
consistency in the documentation process.

©NIIT Input, Output, and Documenting Algorithms Lesson 2B / Slide 19 of 19

You might also like