0% found this document useful (0 votes)
4 views24 pages

Theory p2

The document outlines various programming concepts including data types, algorithms, program constructs, and features of Integrated Development Environments (IDEs). It explains the importance of identifiers, testing data, and the use of subroutines and modules in programming for better management and reusability. Additionally, it discusses methods for error detection and the significance of transferable skills in understanding different programming languages.

Uploaded by

danishwaheed2805
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)
4 views24 pages

Theory p2

The document outlines various programming concepts including data types, algorithms, program constructs, and features of Integrated Development Environments (IDEs). It explains the importance of identifiers, testing data, and the use of subroutines and modules in programming for better management and reusability. Additionally, it discusses methods for error detection and the significance of transferable skills in understanding different programming languages.

Uploaded by

danishwaheed2805
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/ 24

Theory questions

Paper 2
Data types
• Integer: numbers 0-9 without decimal, eg., 95, 768
• Real/float: numbers 0-9 with decimal, eg., 34.6, 59.2
• String: series of characters, enclosed in quotes, eg.,
“House no. 7, street # 2”, “Ahmad”,
• Character: single character, in single quotes, eg., ‘c’,
‘M’, ‘Y’, ‘N’
• Boolean: used for comparisons, either True or False
• Give appropriate data types.
What is data identifier table, and what it
contains?
• It contains list of variables.
• It contains explanation of what that variable does
• Data type of that variable

List of variables Description Data type


Project_completed It will tell the status Boolean
of the project
Algorithm
• Step by step procedure of solving a problem
• Sequence of steps/instruction
• To implement a task/ solution to a problem
• Stages of algorithm
– Input
– Process
– Output
Q: A software developer is writing a program and includes
several features to make it easier to read and understand.
Name those features.
• Indentation
• Blank lines
• Capitalization of keywords
• Sensible variable name
• Comments
• Pretty printing
Few terms
• Source code: it represents a solution/ design/ algorithm
expressed in high level language
• Object code:
– it is produced by the computer during translation stage
– the object code is produced by translating the source code
– not produced by interpreter
• Pseudocode: it is a way of using keywords and identifiers to
describe an algorithm without following the syntax of a
particular language.
• Flowchart: pictorial or graphical representation of a program
in a flow
Types of constructs/program
constructs
• Assignment
• Sequence
• Selection
– IF…THEN…ELSE
– CASE OF … OTHERISE…ENDCASE
• Repeatition/iteration
– FOR…TO…NEXT (counter controlled loop)
– WHILE…DO…ENDWHILE (pre-condition loop)
– REPEAT... UNTIL (post-condition loop)
Types of identifier
• Constants
– Stores a fix value, cannot be changed during program
execution
• Variable
– Stores a value, that can be changed during program
execution
• Arrays
– subscripted variable
– A list of items of the same data type stored under a single
name
Testing of data
• Verification
– Checking that data has not changed during
transfer/input to a computer
– By applying parity check, checksum or double
entry of data
• Validation
– Checking that data meets certain criteria
– By applying different checks, such as, presence
check, length check, format check, character
check
Q: What are the features of a
program?
• Eg., any code can be given in exam and they can ask
this question. Just look at the code and answer what
you find in it. Few examples are given below:
– Function/procedure
– Sequence
– Selection
– Iteration
– Parameters
– Variables
– Logic operations
IDE and its features
• Integrated development environment is a software
application that combines all the features and tools
needed by a software developer.
• Features of an IDE
– Pretty print
– Automatic indentation
– Syntax checking
– Highlights any undeclared variable
– Type checking
Q: What are the features provided in IDE
that assist in Initial Error Detection?
• Dynamic syntax checking
• Type checking
• Identification of unused variabl
Few terms
• Editor
– Produces the source code in high level language
• Translator
– Converts source code into object code
• Debugger
– A debugger is used to test the program or detect errors
Q: Describe methods you could use to
find errors.
• Dry run the program, by using trace table
• Breakpoint: Run the code to set point to find error
• Variable watch: checks the content of variable at
specific point
• Stepping/single stepping: execute the code line by
line
Transferable skills
• Q: There are certain skills that a person has in a certain
language that can be used in another language. List those
skills.
• You should be able to recognize in another language:
– Declaration
– Assignment
– Sequence
– Selection
– Repetition/iteration
– Subroutines
– Parameters passed between module
– Input / output
Question
• An algorithm is presented in a high level language.
Changes are required an the program is given to
Albert, who is an experience programmer but he is
not familiar with the language that has been used.
Explain how Albert would be able to understand the
program?
Answer
• He would use his transferable skills to understand new
programming language.
• He could recognize basic control structures in a language such
as loops, selection statements, declarations etc.
• He could read the comments and meaningful variable names.
What is stepwise refinement?
• The breaking down of an algorithm
• To a level of sufficient (detail) into smaller part
• From which it can be programmed
• Each subtask can be considered as a module that is refined
separately
• Module or subroutine can be either a function or a
procedure
What are the uses of a subroutine in a
program?
• To perform a frequently used operation
within a program,
• that can be called when needed
• That can be reused by another program
Why is it a good practice to construct
a program using modules?
• To make more manageable and
understandable solution
• Subroutine/module may be
independently tested
• Program easier to maintain
What are the advantages of using
subroutine?
• Allows the subroutines to be called into multiple
places
• Subroutine may be tested independently
• If the task changes, changes need to be made only
once
• Reduces unnecessary duplication
• Allows team to work on the different parts of the
solution
Procedure and functions
• Procedure:
– A sequence of steps that is given an identifier and can be
called to perform a sub task (it does not return a value)
• Function:
– A sequence of steps that is given an identifier and can be
called to perform a sub task (it does return a value)
Describe two methods of passing a parameter
between modules.
• By value
– A copy of variable itself is passed and original
value is not changed
• By reference
– The address of the variable is passed so original
value changes in result of any operation.
State how structured programming supports the
implementation of subtasks.
• Subroutines
• Functions
• Procedures
• Parameters

You might also like