Notes Contributed by : Amish Gurung
Explain about Identifier and Variable. How identifier and variable is different? List down the points.
Identifier: The name we use to call a particular entity in a program, which is not a keyword, is called identifier. i.
- Identifier is used to name a variable, function, class, structure, union, etc. ii. It is created to give
- It is created to give unique name to an entity.
- All identifiers are not variable.
Variable: The name given to a distinct memory location which contains a value which may be modified while program gets executed is variable.
- A variable is used to name a memory location, which holds a value.
- Allots a unique name to a particular memory location.
- All variables names are identifiers.
What is Algorithm and flowchart? What is pseudo-code? Why pseudo code is used?
Algorithm: An algorithm is a well-defined procedure that allows a computer to solve a program. It is step-by-step solution to a program.
Flowchart: Flowchart is a graphical representation of the sequential steps in an algorithm.
Pseudo code: It is a method to represent algorithm. Pseudo code is not an actual programming language. It uses short phrases to write code for programs before you actually create it in specified languages. Pseudo code is for programmers own convenience and thus no standard syntax are followed.
Difference between Procedure and Function. Explain about the types of passing parameters type.
- a function returns a value whereas a procedure may or may not return a value or may return more than one value using the output parameters.
- Functions are normally used for computations whereas procedures are normally used for executing business logic.
- Procedure is a bundle of code, it does not have return type whereas function have return type.
- Procedure accepts input or output parameters but function only accepts input parameters.
Passing parameters type:
By value ( byVal ): the actual value is passed into the procedure.
By reference ( byRef ): the address of the variable is passed into the procedure.
What is an array? List down its advantages and disadvantages. Also, explain about the types of an array.
Array: An array is the combination of homogeneous elements with consecutive index number and successive memory locations. The values of an array are called elements of that array.
Advantages of array:
- Microprocessor takes time to search values stored on dispersed location but due to array values become is sequence, so searching process of microprocessor become fast.
- It is used to represent multiple data items of same type by using single identifier name.
- It can be used to implement other data structure like linked lists, stacks, queues, trees, etc.
Disadvantage of an array:
The elements of an array are stored in consecutive memory locations. So, insertion and deletions are very difficult and time consuming.
Types of an array:
- One dimensional array ( 1D ) : It represents and store data in linear form. One dimensional array is a structured collection of component that can be accessed individually by specifying the position of a component with a single index value. One subscript is needed to represent each element in 1D array.
- Two dimensional array ( 2D ) : It represents and store data in matrix form. Two dimensional array is a structured collection of component that can be accessed individually by specifying the position of a component with two index value. Two subscripts are needed to represent each element in 2D array.
What is step-wise refinement, top-down design and structure chart? Explain with appropriate figures about the diagrams used in structure chat.
Step-wise refinement: A way of developing a computer program by first describing general functions, then breaking each function down into details which are refined in successive steps until the whole program is fully defined is step-wise refinement.
Top-down design: An approach in which design begins by specifying complex pieces and then dividing them into successively smaller pieces is top-down design.
Structure chart: A structure chart is a chart which shows the breakdown of a system to its lowest manageable parts. They are used in structured programming to arrange program module into a tree. Each module is represented by a box, which contains the module’s name. The tree structure visualizes the relationships between modules, showing data transfer between modules with using arrows.
Diagram used in structure chart:
Data being passed from module to module that needs to be processed.
Check data sent to process to stop or start process.
It represents a programming modules.
Example of structure diagram:
Programming language: Visual Basic
Dim num1, count, total As Integer
num1 = startMsg()
count = 0
total = 0
While num1 > 0
checkNumber(count, total, num1) : num1 = num1 – 1
Sub checkNumber(ByRef c, ByRef t, ByVal n)
If n Mod 3 = 0 Then
c = divBy3(c)
t = add(n, t)
Return x + 1
Function add(n, t)
Return (n + t)
Console.WriteLine(“program strated, enter your number”) : Return Console.ReadLine()
Console.WriteLine(“checkNumber AddressOf howManyThrees: ” & n)
What is meant by black-box testing, white-box testing and stub testing? Differentiate between black-box and white-box testing.
Black-box testing: In this method the internal structure design or implementation of the item being tested is not known to the tester. Tester is mainly concerned with validation of output rather than how the output is produced. In short, black-box testing is comparing expected value with actual results when program runs.
White-box testing: In this method the internal structure design or implementation of the item being tested is known to the tester. Tester validates the internal structure of the item under consideration along with the output. In short, white-box testing is testing every path through the program code. In IDE setting breakpoints, stepping and subroutine parameter checking are the features that provides to carry out white box testing.
Stub testing: When you develop a user interface, you may wish to test it before you have implemented all the facilities. You can write a ‘stub’ for each procedure. The procedure body only contains an output statement to acknowledge that the call was made.
Difference between Black-box and White-box testing:
|Black-box testing||White-box testing|
|(i) In this testing method, internal structure, design and implementation of the data item being tested is not known to the tester.
(ii) Normally independent software tester’s are responsible for doing black-box testing.
(iii) Programming Implementation and knowledge is not required.
(iv) It means functional test or external test.
|(i) In this testing method, the internal structure, design and implementation of the data item being tested is known to the tester
(ii) Normally software developers are responsible for doing white-box testing.
(iii) Programming Implementation and knowledge is not required.
(iv) It means structural test or interior test.
Define each of the types of an error in a program: syntax error, logic error and run-time error.
Syntax error: ( an error in which a program statement does not follow the rules of the language.)
Syntax errors are errors in the grammar of the program language. That is, the rules of the language have been broken. Common errors are typing errors, such as Selct for Select. Other errors are more subtle, for example:
(i) an If statement without a matching End If statement
(ii) a For statement without a matching Next statement
(iii) an opening parenthesis without a closing parenthesis: (a + b.
Most syntax errors are spotted by the programmer before an attempt to run the code. Some program editors help with this. For example, the Visual Basic.NET editor underlines any variable in the code which has not been declared. Similarly, it highlights declared variables which have not been used in the code. Syntax errors are finally picked up during the syntax analysis stage of the program’s translation. In the case of an interpreter, the error is reported as soon as it is found. A compiler reports all errors found in the complete program in its error report. You should be aware that some editors can report syntax errors while the code is being entered. It is still the syntax analyzer that spots the error. If an examination question asks when a syntax error is found, the answer is “during the syntax analysis stage of the program’s translation”. Often the analyser reports program statements that are not correctly formed. For example, the following statement reports an error:
For Index 1 To 20
The correct Visual Basic syntax is:
For Index = 1 To 20
A similar example is a call to a function that requires two parameters in the function header; an error is reported if the programmer only provides one parameter. Similarly, the programmer may provide the parameter but it is of the wrong data type.
Logic error: ( an error in the logic of the solution that causes program not to behave as intended.)
A logic error occurs when the programmer makes a mistake in their logic for some part of the program. Suppose a programmer wants the first 10 positive integers to be output and creates the following algorithm:
FOR Count = 0 TO 10
This algorithm has no grammatical errors but it does not produce the correct result. It produces the integers 0 to 10 not 1 to 10. This type of error can only be found by thorough testing. The programmer care carefully check the code by reading it or can attempt to run the program. Another common error is to use the wrong arithmetic symbol, e.g. a+b instead of a-b, or to put parentheses in the wrong place, such as (a+b-c)*d instead of (a+b)-c*d. These errors should be identified during testing and are all a mistake in the logic of the programmer.
Run-time error: ( an error that cause program execution to crash or freeze. )
Run-time errors occur during the execution (running) of the program. A typical error is to have an expression, such as (a+b)/(c-d), used in the program but c is equal to d, resulting in an attempted division by zero. The problem is that this error may be undetected for a considerable time because the equality of c and d rarely happens. However, it could be disastrous when it does. It is a good idea to test the denominator before division to ensure that this error doesn’t crash the program. Instead, the programmer “traps” the error and displays an error message, as seen in the following code:
Dim A, B, C, D As Integer
Dim Denominator As Single
A = InputBox(“A …”)
B = InputBox(“B …”)
C = InputBox(“C …”)
D = InputBox(“D …”)
If C <> D Then
Denominator = C – D
Console.writeline (“Answer is … ” & Denominator)
Console.writeline (“Denominator is Zero”)
What is Dry-run and trace table? Explain about the debugging features of the programming environment: breakpoint and stepping.
Dry-run: The process of checking the execution of an algorithm or program by recording variable values in a trace table.
Trace table: A table with a column for each variable that records their changing value.
Debugging features of the programming environment: Breakpoint and Stepping
Breakpoint: It is a signal that tells the debugger to temporarily suspend execution of your program at a certain point. A point where the program can be halted to see if the program works at this point.
Stepping: When your program is in break mode – that is, the program has paused at a breakpoint – you can control how execution continues or Executes one statement at a time and then pauses to see the effect of each statement.
What is an Integrated Development Environment ( IDE )? Describe some of the features provides by IDE.
Integrated Development Environment ( IDE ): It is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consist of source code editor, build automation tools and a debugger.
Features of Integrated Development Environment ( IDE ):
i. Pretty printing: pretty print refers to the presentation of the program code typed into an editor. It includes indentation, color – coding of keywords and comments.
ii. Context – sensitive prompts: this features displays hints or a choice of keywords and available identifiers appropriate at the current insertion point of the program code.
iii. Dynamic syntax check: When a line has been typed, some editor perform syntax check and alert the programmer to errors.
iv. Expanding and collapsing code blocks: When working on program code consisting of many lines of code, it saves excessive scrolling if you can collapse blocks of statements.
Explain about the programming constructs.
Assignment statement: Code that gives a value to a variable or constant.
Example: MyAge ← 4, in pseudo code, assigns the value 4 to the variable MyAge.
Sequence statement: programming statements are executed consequently, as they appear in the program.
Selection statement: any program statement in which a decision is made.
• IF Statement
• SELECT Statement
Iteration/Repetition: control structure in which a block of code is repeated a number of times.
• FOR Loop: It is count controlled loop where there is no condition.
• Do Loop: In this loop condition is given at the end of statement.
• WHILE Loop: In this loop condition is given at the start of statement.
Explain or differentiate: post-condition and pre-condition loop.
Post-condition Loop: It executes the statements within loop at least once. When the condition is encountered, it is evaluated. As long as condition evaluates to False the statements within loop are executed again. When then condition evaluates to True, execution will go to the next statement after the loop.
Pre-condition Loop: It evaluates the condition before the statements within the loop are executed. Pre-condition loops will execute the statements within the loop as long as the condition evaluates to True. When the condition evaluates to False, execution will go to the next statement after the loop.
What is Transferable Skill? Why Programming in a high-level language is a transferable skill?
Transferable Skills: Ability to define a specific problem in a particular situation, understand and expand the learns of broad generality that can be applied in other in other situation or field, and develop the use cases that solve the specific problem in such a way as the tool developed can be applied to the broader case.
Programming in a high-level language is a transferable skill:
i. Similar syntax
– Assignment, variable, data types
– Common operators, Symbols for functions
ii. Control structures
– Iteration – Selection
– Layout, format (e.g. indentation )
iii. Modular features
– Procedures , Functions
List down differences and similarities between Built-in function and user-defined function.
- Built-in functions are made available by the programming language i.e., already in the system
- Built-in functions are ready made and tested
- User-defined functions can be modified whereas built-in cannot be modified
- User defined functions can be designed to meet the user’s requirements
- User-defined functions can only be used in the program or module
- They have an identifier name
- They return a value
- They have none, one or more arguments
- Both perform a specific task
- Both represent re-usable code
- Both are ‘called’
Where source code is written? And what produces object code?
Text Editor creates or modifies the source code using the text editor.
Compiler translates the source code and produces the object code.
A compiler takes a program written in a high-level language (called the source program, which is made up of source code) and translates it into an equivalent program in machine code (called the object program or object file, which is made up of object code). Once this is done, the machine code version can be loaded into the machine and executed without any further involvement of the compiler
What is constant variable? Explain its benefit in a program?
Constant variable: In computer programming, a constant is a value that cannot be altered by the program during normal execution.
One benefit of using constants is that its value will not change accidentally. It makes our program easier to modify.
What is corrective maintenance and adaptive maintenance?
Corrective maintenance: (Correcting identified errors) Corrective maintenance is a maintenance task or operation done in order to identify, isolate or separate and rectify a particular fault. This is performed in order to restore the failed machine, equipment or system to an operational condition. Corrective maintenance is necessary when a fault or bug is found in the operation of the new system. These are software bugs which were not picked up at the formal testing stage. A technician or the original programmers will be needed to correct the error.
Adaptive maintenance: The action of making amendments to a program to enhance functionality or in response to specification changes.
Adaptive maintenance is necessary when conditions change from those that existed when the original system was created. This may be because of a change in the law (tax rates may change, for example) or the hardware may be changed, so that changes need to be made to the software for it to remain functional.
What is Rogue value? Explain with an example.
Rogue value: A specific value, outside the generally expected range, which is used to terminate a list of data items.
Consider the following simple program:
Program to print number from 1 to 8 ( both inclusive ) :
Dim i As Integer = 1
i = i + 1
Loop Until i = 9 ‘Here 9 is rogue value which is used to terminate the loop.
Difference between a parameter and an argument.
Parameters are temporary variable names within functions. The argument can be thought of as the value that is assigned to that temporary variable. Within the function, parameters act as placeholders for the argument it is passed.
For instance, let’s consider following simple function to cube a number.
Function Cube (byVal number as integer) as integer
‘number’ here is the parameter for the function ‘cube’. This means that anywhere we see ‘number’ within the function will act as a placeholder until number is passed an argument. To pass an argument to a function is do something like, cube(3), which will call ‘cube’ function and would assign the value 3 ( pass the argument 3 ) to the parameter ‘number’. Now whatever you see the parameter ‘number’ within the function, it will act like a variable with the value of 3. So, it will return 3 cubed which is 27.
- Cambridge International AS and A level Computing Course book (Chris Leadbetter, Roger Blackford and Tony Piper)
- Cambridge International AS and A level Computer Science Course book (Sylvia Langfield and Dave Duddell)
- Wikipedia, Yahoo, Stackoverflow and many other random websites.
- Cambridge International computer science (9608) past papers.