Professional Documents
Culture Documents
CP-EXAMEN!!!!: Algorithm, Given Both The Problem and The Device: Precise Characterization of A
CP-EXAMEN!!!!: Algorithm, Given Both The Problem and The Device: Precise Characterization of A
Algorithm, given both the problem and the device: precise characterization of a
method of solving the problem, presented in a language comprehensible to the
device.
Properties:
◼ Application of the algorithm to a particular input set or problem description
results in a finite sequence of actions.
◼ The sequence of actions has a unique initial action.
◼ Each action in the sequence has a unique successor.
◼ The sequence terminates with either a solution to the problem, or a statement
that the problem is unsolvable for that set of data.
EXPRESSION EVALUATION
◼Prefix: in evaluation the value after increment/decrement is used,
e.g. x=10; y=++x; /* y=11 and x=11 */
◼ Postfix: the value before increment/decrement is used in evaluation
x=10; z=x++; /* z=10 and x=11 */
COMMON C ERRORS:
double half = 1/2;
◼This sets half to 0 not 0.5!
◼ 1 and 2 are integer constants.
◼ At least one needs to be floating point: double half = 1.0/2;
◼ Or cast one to floating point: int a = 1, b = 2; double half =
((double)1)/2.