Download - Problem Solving With Computers
![Page 1: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/1.jpg)
Beginning Problem-Solving Concepts for the ComputerProblem Solving and Programming Concepts by Sprankle and Hubbard
![Page 2: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/2.jpg)
Overview
Constants and Variables
Data Types
How the Computer Stores Data
Functions
Operators
Expressions and EquationsBullet, etc
![Page 3: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/3.jpg)
Objectives1. Differentiate between variables, constants.
2. Differentiate between character, numeric, and logical data types.
3. Identify operators, operands, resultants.
5. Identify, use functions
6. Identify, use operators according to placement in hierarchy chart.
7. Set up, evaluate expressions and equations using variables, constants, operators, and the hierarchy of operations.
![Page 4: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/4.jpg)
Important Concepts to Learn
![Page 5: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/5.jpg)
Constant
A specific alphabetical and/or numeric value that never changes during the processing of all the instructions in a solution.
Constants can be any type of data—numeric, alphabetical, or special symbols.
![Page 6: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/6.jpg)
Variable
Value that can change Called as Identifiers in many languages The programmer uses a variable name as a
reference name for a specific value of the variable
The computer sets up a specific memory location to hold the value of each variable name found in a program
![Page 7: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/7.jpg)
![Page 8: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/8.jpg)
Rules for Naming and Using Variables Name a variable according to what it
represents Hours for hours worked PayRate for rate of pay
Do not use spaces in a variable name use HoursWorked instead of Hours Worked;
Start a variable name with a letter;
![Page 9: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/9.jpg)
Rules for Naming and Using Variables Do not use a dash (or any other symbol that is
used as a mathematical operator) in a variable name. The computer will recognize these symbols as
mathematical operators, turn your variable into two or more variables, and treat your variable as a mathematical expression;
After you have introduced a variable name that represents a specific data item, this exact variable name must be used in all places where the data item is used;
![Page 10: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/10.jpg)
Rules for Naming and Using Variables Be consistent when using upper- and lower-
case characters. In some languages HOURS is a different
variable name than Hours;
Use the naming convention specified by the company where you work.
![Page 11: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/11.jpg)
![Page 12: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/12.jpg)
Data Types
Data are unorganized facts. They go into the computer as input and are processed by the program.
What is returned to the user is output, or information. This information is printed in the form of reports.
![Page 13: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/13.jpg)
![Page 14: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/14.jpg)
The data the computer uses are of many different types.
The most common data types are numeric, character, and logical
Data Types
![Page 15: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/15.jpg)
Numeric Data
Numeric is the only data type that can be used in numeric calculations.
The subtypes of numeric data include integers and real numbers. Integers are whole numbers, such as 5,297 or -376.
They can be positive or negative.
Real numbers, or floating point numbers, are whole numbers with decimal parts.
![Page 16: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/16.jpg)
Numeric Data
Each data type has a data set, the set of symbols necessary to specify a datum as a particular data type.
A data set is the set of values that are allowed in a particular data type.
The data set for the numeric data type includes all base 10 numbers, the plus sign (+) and the negative sign (-).
![Page 17: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/17.jpg)
![Page 18: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/18.jpg)
Character Data—Alphanumeric Data The character data set, sometimes called
alphanumeric data set, consists of all single digit numbers, letters, and special characters available to the computer.
An upper case letter is considered a different character from a lower case letter.
Characters cannot be used for calculations even if they consist of only numbers.
![Page 19: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/19.jpg)
Character Data—Alphanumeric Data When more than one character are put
together, the computer considers this item a string
Character and string data can be compared and arranged in alphabetical order in the following way.
![Page 20: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/20.jpg)
Character Data—Alphanumeric Data Character data or string data can be joined
together with the + operator in an operation called concatenation. aa + bb = aabb Rose + Daisy = RoseDaisy
![Page 21: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/21.jpg)
Logical Data
Logical data consist of two values in the data set: True or False Yes or No 1 or 2
![Page 22: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/22.jpg)
Rules for Data Types
1.The data that define the value of a variable or a constant will most commonly be one of three data types: numeric, character, or logical.
2.The programmer designates the data type during the programming process. The computer then associates the variable name with the designated data type.
3.Data types cannot be mixed.
![Page 23: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/23.jpg)
Rules for Data Types
4. Each of the data types uses what is called a data set.
5. Any numeric item that must be used in calculations resulting in a numeric result must be designated as numeric data type.
![Page 24: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/24.jpg)
![Page 25: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/25.jpg)
Functions
small sets of instructions that perform specific tasks and return values.
used as parts of instructions in a solution.
FunctionName(data)
![Page 26: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/26.jpg)
Functions
Functions use data. The data is listed as part of the function and are called parameters.
Examples: square root function, Sqrt(N) The maximum function, Max(N1, N2,N3)
![Page 27: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/27.jpg)
Classes of Functions
1. Mathematical functions. Often used in science and business, mathematical functions calculate such things as square root, absolute value, or a random number.
2. String functions. These are used to manipulate string variables.
3. Conversion functions. These functions are used to convert data from one data type to another.
![Page 28: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/28.jpg)
Classes of Functions
4. Statistical functions. These functions are used to calculate things such as maximum values, minimum values, and so forth.
5. Utility functions. This class is very important in business programming because most reports require some use of utility functions.
![Page 29: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/29.jpg)
Mathematical Function
![Page 30: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/30.jpg)
String Function
![Page 31: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/31.jpg)
![Page 32: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/32.jpg)
![Page 33: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/33.jpg)
Operators
Operators are the data connectors within expressions and equations.
They tell the computer how to process the data. Operands and Resultant
Operands are the data that the operator connects and processes.
The resultant is the answer that results when the operation is completed.
![Page 34: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/34.jpg)
Mathematical operators
Include addition, subtraction, multiplication, division, integer division, modulo division, powers, and functions Integer Division - the resultant is the whole number
in the quotient. Modulo Division - the resultant is the whole number
remainder.
![Page 35: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/35.jpg)
Operators and Their Computer Symbols
![Page 36: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/36.jpg)
Relational operators
include the following: equal to, less than, greater than, less than or equal to, greater than or equal to, and not equal to.
A programmer uses relational operators to program decisions.
The resultant of a relational operation is logical data type True or False.
Relational operators are also used to control repetitive instructions called loops.
![Page 37: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/37.jpg)
Operators and Their Computer Symbols
![Page 38: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/38.jpg)
Logical operators
Logical operators are used to connect relational expressions (decision-making expressions) and to perform operations on logical data.
![Page 39: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/39.jpg)
Logical operators
![Page 40: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/40.jpg)
Logical operators
![Page 41: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/41.jpg)
Operators and Their Computer Symbols
![Page 42: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/42.jpg)
Expressions and Equations
An expression processes data, the operands, through the use of operators.
Length * Width
An equation stores the resultant of an expression in a memory location in the computer through the equal sign.
Area = Length * Width
![Page 43: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/43.jpg)
Expressions and Equations
![Page 44: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/44.jpg)
Evaluating a Mathematical Expression
5 * (X + Y) - 4 * Y>(Z + 6)
Where:
X = 2 Y = 3 Z = 6
![Page 45: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/45.jpg)
Evaluating a Relational Expression
![Page 46: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/46.jpg)
Evaluating a Logical Expression
![Page 47: Problem Solving With Computers](https://reader034.vdocuments.us/reader034/viewer/2022052414/563dbb88550346aa9aadfea8/html5/thumbnails/47.jpg)
Evaluating an Equation That Uses BothRelational and Logical Operators