The three kinds of programming errors:
• Syntax errors
• Run-time errors
• Logical errors
• Syntax errors:
These errors occur in the grammatical rules such as missing semicolons, misspelled words and declarations part is absent.
int number syntax error; because semicolon is missing in the end
• Run-time errors:
A Runtime error occurs when execution of a program. The runtime errors are divisible by zero, illegal memory access, and try to determine the square root of a negative number.
int p = 40, q = 20, r = 20;
int answer = p / (q - r); Run-time error; because it's divisible by zero
int result = p / (q + r);
• Logical error:
In logical error, program execution is correct however the corresponding program does not generate the exact output.
Totalmonths = 13;
result = Total / Totalmonths;
In the above example, program executed successfully, but it will generate the wrong output; because the "Totalmonths" is 12 but in the above example Totalmonths = 13.
The Pseudo code is a combination of normal language with symbols that can be used as procedure for the solving the problem.
It is generally written in common language to understand the terms and does not require any syntax for defining the problem which makes it easy for better understanding of problem and could be easy in implementing in one or more high level programming languages.
The following pseudocode is used to find the maximum of two numbers:
if a is greater than b then
print a is maximum
print b is maximum
When analyzing the given program segment, it is used to check the whether the given search item is found in the given matrix or not. If the search item is found, it returns true. Otherwise returns false.
In the problem 1, the variable "found" is not declared and initialized which means "bool found = false" is missing in the given program.
Another reason is that cannot use the goto statement in given program which is not structured.
• The given program is used to check whether the search item is found in the given matrix or not.
• The given program is not efficient to problem 1. Because in this program, the matrix is searched completely and find out the given searched value is present in the matrix or not using "found" variable.
• But in the problem 1, variable "found" is not declared and initialized. So that program cannot return the given search item is found or not.
• So given program is not efficient to problem "1". After inserting the "bool found = false", it will return the search item.