Professional Documents
Culture Documents
Beginning Problem-Solving Concepts For The Computer
Beginning Problem-Solving Concepts For The Computer
BEGINNING PROBLEM-SOLVING
CONCEPTS FOR THE COMPUTER
Chapter 2
3 Types of Problems that can be solved on
computers :
2
Computational
problems involving some kind of mathematical
processing
Logical
Problems involving relational or logical processing
Repetitive
Problems involving repeating a set of mathematical
and/or logical instructions.
Fundamental Concepts
3
Variables
Operators
Functions
Expressions
equations
Constants
4
A value
a specific alphabetical and/or numeric value
Does not change during the processing of all the
instructions in a solution
Can be of any data type
Numeric, alphabetical or special symbols
Examples
3, 5, 10, “Sara”, “+”, “-”, “/”
Constants
5
Example
SalesTaxRate =6
Commission_Rate = 6
For example:
√ StudentName for student name (correct).
x Student-Name Incorrect because using a dash symbol.
13
Data
unorganized facts.
They go into the computer as input .
Information
The output of processing of input .
Is printed in the form of reports.
Processing Data – How a computer
Balances a Checkbook
17
Checks
Deposits Calculates the Balance
Bank Charge Balance Sheet
Data Types
18
21
Character Types
22
B 66 b 98
C 67 c 99
D 68 d 100
E 69 e 101
COP1006 McManus
Comparing Characters & Strings
28
Data Storage
Each variable name is given a memory location
Each memory location can hold one and only one
value at a time.
This memories are temporary storage, when a user
enters a new value the old one is destroyed
Example:
COP1006 McManus
Functions
37
1. Mathematical
Used in science and business , Calculate such things as
square root, absolute value
2. String
Manipulate string variable
3. Conversion
Convert data from one data type to another
4. Statistical
5. Utility
Important in business programming
Mathematical Functions
41
1. Mathematical
The data types of operands and resultants of
mathematical operators are always numeric
+, -, *, /
\, Mod ( used in business )
^
functions
Two Special Math Operators
49
Relational operators
Perform comparisons
the use of relational operators is the only way for the
computer to make decisions .
The resultant of relational operation is logical data type .
The operand s can be numeric or character
Relational operatores
A B A AND B
True True True
True False False
False True False
False False False
The OR Operator
56
A B A OR B
True True True
True False True
False True True
False False False
The NOT Operator
57
A NOT A
True False
False True
Hierarchy of Operations
58
False
True
False
False
False
False
True
True
True
Expressions & Equations
62
Expressions
Process the data and the operands, through the use
of the operators
Does not store the resultant (answer)
Examples :
Length * Width
Equations
63
Examples
A+B C= A + B
A and B are numeric. C ,A and B are numeric.
The resultant is numeric and is The resultant is stored in C .
not stored
A<B C=A<B
A and B are numeric , character, A and B are numeric , character,
or string. or string .
The resultant is logical and is The resultant is stored in C ;
not stored . C is logical.
A OR B C = A OR B
A and B are logical . C ,A and B are logical .
The resultant is logical and is The resultant is stored in C .
not stored
Example : evaluating a mathematical
expression .
5*(X+Y)–4*Y/(Z+6)
uses the following values to evaluate the expression :
A–2B
uses the following values to evaluate the expression :
A = 6 b= 8
Operation resultant
1. A – 2 4
2. Resultant of 1 B false
Example : evaluating a logical expression .
A AND B OR C AND A
uses the following values to evaluate the expression :
(X Y)
Y = (X – Y) / ( (X + Y)^2 / (X – Y )^2 )
(X Y )2
(X Y )2 straight line form
Attachment: ASCII Coding
69
COP1006 McManus