SlideShare a Scribd company logo
1 of 17
Download to read offline
Data Structures and Algorithms




     Constants and
     Variables

Constants
 @ a value, that is, a specific alphabetical and/or
       numeric value, that never changes during the
       processing of all the instructions in a solution
 @ can be any type of data - numeric, alphabetical,
       or special symbols


Variable
 @ may change during processing

 @ the computer sets up a specific memory location
       to hold the value of each variable name found in a
       program
 @ can be any data type, just as constant



Beginning Problem-Solving Concepts for the Computer                     Page 1 of 17
Data Structures and Algorithms




     Constants and
     Variables

 Rules for Naming and Using Variables
 @ Name a variable according to what it reperesents,
   that is, HOURS for hours worked, PAYRATE for rate
   of pay, and so on.

 @ Do not use spaces in a variable name. If a space is
   needed, use the underline character.

 @ Do not use a dash (or any 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.




Beginning Problem-Solving Concepts for the Computer                     Page 2 of 17
Data Structures and Algorithms




     Constants and
     Variables


 Rules for Naming and Using Variables

 @ 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.

 @ Be consistent when using upper- and lowercase
   characters.




Beginning Problem-Solving Concepts for the Computer                     Page 3 of 17
Data Structures and Algorithms




       Data Types


Data
  @ unorganized facts

Information
  @ what is returned to the user as output, or
       processed data



                            Input                Data       Output
        DATA                               Processed into                      REPORT
                                             Information



      Checks
                                             Calaculates
     Deposits                                                              Balance Sheet
                                             the balance
     Bk. Chgs.




Beginning Problem-Solving Concepts for the Computer                                    Page 4 of 17
Data Structures and Algorithms




       Data Types



       Data Type                           Data Set              Examples
      Numeric: Integer                 All whole numbers            3570 , -54
                                  All real numbers (whole +
       Numeric: Real                        decimal)           3792.91, 474526.23
        CHARACTER
       (surrounded by              All letters, numbers, and    "A","a", "M", "1",
      quotation marks)                  special symbols           "88","&", "#"

   STRING (surrounded               Combinations of more
   by quotation marks)               than one character        "waahhh", "876860"
        LOGICAL                       TRUE FALSE                 TRUE FALSE




Beginning Problem-Solving Concepts for the Computer                                Page 5 of 17
Data Structures and Algorithms




       Data Types



                              Data                         Data Type
           The price of an item: 12.50, 34.00              Numeric: real

               An account number: "A8693"                 Character String
                    A quantity: 10,345                    Numeric: integer

               The name of a school: "STI"                Character String

              A credit check: TRUE, FALSE                      Logical

              A date: 06/21/03 or "01/11/81           Date or Character String




Beginning Problem-Solving Concepts for the Computer                            Page 6 of 17
Data Structures and Algorithms




       Data Types



Rules for Data Types
@ The data that define the value of a variable or a
  constant will most commonly be one of three data
  types: numeric, character (including character
  string), or logical.

@ The programmer designates the data type during
  the programming process. The computer then
  associates the variable name with the designated
  data type.

@ Data types cannot be mixed.




Beginning Problem-Solving Concepts for the Computer                     Page 7 of 17
Data Structures and Algorithms




       Data Types


Rules for Data Types

@ Each of the data types uses what is called a data
  set. The numeric data uses the set of all base 10
  numbers, the plus sign (+), and the negative sign
  (-); the character type uses the set of data
  consisting of the words TRUE and FALSE. The use
  of any data outside the data set results in an error.

@ Any numeric item that must be used in calculations
  resulting in a numeric results must be designated
  as numeric data type. All other numbers should be
  designated as character or character-string data
  types, even if data are all numbers.




Beginning Problem-Solving Concepts for the Computer                     Page 8 of 17
Data Structures and Algorithms




         Functions

         @ small sets of instructions that perform
               specific tasks and return values

         @ usually built into a computer language or
               application

         @ used as parts of istructions in a solution


Classes of Functions:
          a     Mathematical
          a     String
          a     Conversion
          a     Statistical
          a     Utility




Beginning Problem-Solving Concepts for the Computer                     Page 9 of 17
Data Structures and Algorithms




         Functions



                                           Example            Result
                                            SQRT(4)             2
     Mathematical                           ABS (-3)            3
                                         ROUND (5.678)          6
                                        INTEGER (5.789)         5




                                           Example            Result
                String               MID(S, 3, 2) where S =
                                          "THOMAS"            "OM"
                                     LEFT (S,3) where S =
                                          "THOMAS"            "THO"
                                     RIGHT (S, 3) where S=
                                          "THOMAS"            "MAS"
                                     LENGTH(S) where S =
                                          "THOMAS"              6




Beginning Problem-Solving Concepts for the Computer                            Page 10 of 17
Data Structures and Algorithms




         Functions


                                            Example        Result
     Conversion                           VALUE ("57")      +57
                                          STRING (+57)      "57"



    Statistical                           Example             Result
                                      AVERAGE (1,2,3,4)        2.5
                                        MAX (1,2,3,4)           4
                                        MIN (1,2,3,4)           1
                                        SUM (1,2,3,4)          10


            Utility                            Example       Result
                                                DATE         6/22/03
                                                TIME         2:55:03




Beginning Problem-Solving Concepts for the Computer                        Page 11 of 17
Data Structures and Algorithms




         Operators


  @ the data connectors within expressions and
       equations
  @ tell the computer how to process the data

  @ tell the computer what type of processing
       (mathematical,logical or whatever) needs to be
       done

Types of Operator
  @ Mathematical - include addition, subtraction,
       multiplication, division, integer division, modulo
       division, powers, and functions

  @ Relational - = , <, >, >=, <=, <>

  @ Logical - AND, NOT, and OR



Beginning Problem-Solving Concepts for the Computer                    Page 12 of 17
Data Structures and Algorithms




         Operators

     Mathematical

               Operation                       Resultant
               3.0 + 5.2                         8.2
                7.5 - 4.0                        3.5
                8.0 * 5.0                         40
                 9.0/4.0                          2
                   94                            2
               9 MOD 4                            1
                  3^2                             9


     Relational
               Operation                      Resultant
                 3=2                           FALSE
                  5>1                          TRUE
                 5=1                           FALSE
                7 <= 8                         TRUE
                9>=12                          FALSE
                10 < 2                         TRUE
                 8<>8                          FALSE




Beginning Problem-Solving Concepts for the Computer                         Page 13 of 17
Data Structures and Algorithms




         Operators

   Logical

                     A                         Not A
                     T                          F
                     F                          T




                      A                               B       A AND B
                      T                               T          T
                      T                               F          F
                      F                               T          F
                      F                               F          F




                       A                                  B     A OR B
                       T                                  T        T
                       T                                  F        T
                       F                                  T        T
                       F                                  F        F


Beginning Problem-Solving Concepts for the Computer                               Page 14 of 17
Data Structures and Algorithms




         Operators

Hierarchy of Operations
 ( ) Reorders the hierarchy; all operations are
 completed within the parentheses using the same
 hierarchy.

      1. Functions

      Mathematical:
      2. Power
      3. , MOD
      4. *, /
      5. +, -

      Relational:
      6. =, <, >, <=, >=, <>

      Logical:
      7. NOT
      8. AND
      9. OR
Beginning Problem-Solving Concepts for the Computer                    Page 15 of 17
Data Structures and Algorithms




     Expressions and
     Equations

Expression
  @ processes data, the operands, through the use of
       operators
  @ example: LENGTH * WIDTH


Equation
  @ stores the resultant of an expression in a memory
       location in the computer through the equal (=) sign
  @ example: AREA = LENGTH * WIDTH

  @ often called assignment statements because the
       variable on the left-hand side of the equal sign is
       assigned the value of the expression on the right-
       hand side
  @ the equal sign does not mean equals; instead it
       means replaced by or is assigned the value of

Beginning Problem-Solving Concepts for the Computer                    Page 16 of 17
Data Structures and Algorithms




              Expressions and
              Equations




Beginning Problem-Solving Concepts for the Computer                 Page 17 of 17

More Related Content

What's hot

3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
koolkampus
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
koolkampus
 
Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582
Editor IJARCET
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
eidah20
 

What's hot (20)

3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
DBMS_INTRODUCTION OF SQL
DBMS_INTRODUCTION OF SQLDBMS_INTRODUCTION OF SQL
DBMS_INTRODUCTION OF SQL
 
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
 
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
 
DBMS_Ch1
 DBMS_Ch1 DBMS_Ch1
DBMS_Ch1
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
Lesson 1 overview
Lesson 1   overviewLesson 1   overview
Lesson 1 overview
 
DBMS_intermediate sql
DBMS_intermediate sqlDBMS_intermediate sql
DBMS_intermediate sql
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013
 
Database Assignment
Database AssignmentDatabase Assignment
Database Assignment
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY  MILAN PATELCHAPTER 2 DBMS IN EASY WAY BY  MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
 
Relational database intro for marketers
Relational database intro for marketersRelational database intro for marketers
Relational database intro for marketers
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
 

Similar to 2 beginning problem solving concepts for the computer

DatumTron In-Memory Graph Database
DatumTron In-Memory Graph DatabaseDatumTron In-Memory Graph Database
DatumTron In-Memory Graph Database
Ashraf Azmi
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
iamsallauddin
 
spss-anintroduction-150704135929-lva1-app6892.pdf
spss-anintroduction-150704135929-lva1-app6892.pdfspss-anintroduction-150704135929-lva1-app6892.pdf
spss-anintroduction-150704135929-lva1-app6892.pdf
jainishbhagat1
 
Basic MATLAB Programming PPT.pptx
Basic MATLAB Programming PPT.pptxBasic MATLAB Programming PPT.pptx
Basic MATLAB Programming PPT.pptx
BajiBabu17
 

Similar to 2 beginning problem solving concepts for the computer (20)

Programming
ProgrammingProgramming
Programming
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
Generating test data for Statistical and ML models
Generating test data for Statistical and ML modelsGenerating test data for Statistical and ML models
Generating test data for Statistical and ML models
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Mscs discussion
Mscs discussionMscs discussion
Mscs discussion
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Sql.pptx
Sql.pptxSql.pptx
Sql.pptx
 
Data Processing-Presentation
Data Processing-PresentationData Processing-Presentation
Data Processing-Presentation
 
Arrays
ArraysArrays
Arrays
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Ch3
Ch3Ch3
Ch3
 
Spss an introduction
Spss  an introductionSpss  an introduction
Spss an introduction
 
Excel Training
Excel TrainingExcel Training
Excel Training
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
DatumTron In-Memory Graph Database
DatumTron In-Memory Graph DatabaseDatumTron In-Memory Graph Database
DatumTron In-Memory Graph Database
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
 
spss-anintroduction-150704135929-lva1-app6892.pdf
spss-anintroduction-150704135929-lva1-app6892.pdfspss-anintroduction-150704135929-lva1-app6892.pdf
spss-anintroduction-150704135929-lva1-app6892.pdf
 
Project
ProjectProject
Project
 
Basic MATLAB Programming PPT.pptx
Basic MATLAB Programming PPT.pptxBasic MATLAB Programming PPT.pptx
Basic MATLAB Programming PPT.pptx
 

More from Rheigh Henley Calderon (20)

10 data structures
10 data structures10 data structures
10 data structures
 
9 processing arrays
9 processing arrays9 processing arrays
9 processing arrays
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structure
 
7 problem solving with loops
7 problem solving with loops7 problem solving with loops
7 problem solving with loops
 
6 problem solving with decisions
6 problem solving with decisions6 problem solving with decisions
6 problem solving with decisions
 
5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure
 
4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
 
3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
9 technical support
9 technical support9 technical support
9 technical support
 
8 customer service
8 customer service8 customer service
8 customer service
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

2 beginning problem solving concepts for the computer

  • 1. Data Structures and Algorithms Constants and Variables Constants @ a value, that is, a specific alphabetical and/or numeric value, that never changes during the processing of all the instructions in a solution @ can be any type of data - numeric, alphabetical, or special symbols Variable @ may change during processing @ the computer sets up a specific memory location to hold the value of each variable name found in a program @ can be any data type, just as constant Beginning Problem-Solving Concepts for the Computer Page 1 of 17
  • 2. Data Structures and Algorithms Constants and Variables Rules for Naming and Using Variables @ Name a variable according to what it reperesents, that is, HOURS for hours worked, PAYRATE for rate of pay, and so on. @ Do not use spaces in a variable name. If a space is needed, use the underline character. @ Do not use a dash (or any 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. Beginning Problem-Solving Concepts for the Computer Page 2 of 17
  • 3. Data Structures and Algorithms Constants and Variables Rules for Naming and Using Variables @ 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. @ Be consistent when using upper- and lowercase characters. Beginning Problem-Solving Concepts for the Computer Page 3 of 17
  • 4. Data Structures and Algorithms Data Types Data @ unorganized facts Information @ what is returned to the user as output, or processed data Input Data Output DATA Processed into REPORT Information Checks Calaculates Deposits Balance Sheet the balance Bk. Chgs. Beginning Problem-Solving Concepts for the Computer Page 4 of 17
  • 5. Data Structures and Algorithms Data Types Data Type Data Set Examples Numeric: Integer All whole numbers 3570 , -54 All real numbers (whole + Numeric: Real decimal) 3792.91, 474526.23 CHARACTER (surrounded by All letters, numbers, and "A","a", "M", "1", quotation marks) special symbols "88","&", "#" STRING (surrounded Combinations of more by quotation marks) than one character "waahhh", "876860" LOGICAL TRUE FALSE TRUE FALSE Beginning Problem-Solving Concepts for the Computer Page 5 of 17
  • 6. Data Structures and Algorithms Data Types Data Data Type The price of an item: 12.50, 34.00 Numeric: real An account number: "A8693" Character String A quantity: 10,345 Numeric: integer The name of a school: "STI" Character String A credit check: TRUE, FALSE Logical A date: 06/21/03 or "01/11/81 Date or Character String Beginning Problem-Solving Concepts for the Computer Page 6 of 17
  • 7. Data Structures and Algorithms Data Types Rules for Data Types @ The data that define the value of a variable or a constant will most commonly be one of three data types: numeric, character (including character string), or logical. @ The programmer designates the data type during the programming process. The computer then associates the variable name with the designated data type. @ Data types cannot be mixed. Beginning Problem-Solving Concepts for the Computer Page 7 of 17
  • 8. Data Structures and Algorithms Data Types Rules for Data Types @ Each of the data types uses what is called a data set. The numeric data uses the set of all base 10 numbers, the plus sign (+), and the negative sign (-); the character type uses the set of data consisting of the words TRUE and FALSE. The use of any data outside the data set results in an error. @ Any numeric item that must be used in calculations resulting in a numeric results must be designated as numeric data type. All other numbers should be designated as character or character-string data types, even if data are all numbers. Beginning Problem-Solving Concepts for the Computer Page 8 of 17
  • 9. Data Structures and Algorithms Functions @ small sets of instructions that perform specific tasks and return values @ usually built into a computer language or application @ used as parts of istructions in a solution Classes of Functions: a Mathematical a String a Conversion a Statistical a Utility Beginning Problem-Solving Concepts for the Computer Page 9 of 17
  • 10. Data Structures and Algorithms Functions Example Result SQRT(4) 2 Mathematical ABS (-3) 3 ROUND (5.678) 6 INTEGER (5.789) 5 Example Result String MID(S, 3, 2) where S = "THOMAS" "OM" LEFT (S,3) where S = "THOMAS" "THO" RIGHT (S, 3) where S= "THOMAS" "MAS" LENGTH(S) where S = "THOMAS" 6 Beginning Problem-Solving Concepts for the Computer Page 10 of 17
  • 11. Data Structures and Algorithms Functions Example Result Conversion VALUE ("57") +57 STRING (+57) "57" Statistical Example Result AVERAGE (1,2,3,4) 2.5 MAX (1,2,3,4) 4 MIN (1,2,3,4) 1 SUM (1,2,3,4) 10 Utility Example Result DATE 6/22/03 TIME 2:55:03 Beginning Problem-Solving Concepts for the Computer Page 11 of 17
  • 12. Data Structures and Algorithms Operators @ the data connectors within expressions and equations @ tell the computer how to process the data @ tell the computer what type of processing (mathematical,logical or whatever) needs to be done Types of Operator @ Mathematical - include addition, subtraction, multiplication, division, integer division, modulo division, powers, and functions @ Relational - = , <, >, >=, <=, <> @ Logical - AND, NOT, and OR Beginning Problem-Solving Concepts for the Computer Page 12 of 17
  • 13. Data Structures and Algorithms Operators Mathematical Operation Resultant 3.0 + 5.2 8.2 7.5 - 4.0 3.5 8.0 * 5.0 40 9.0/4.0 2 94 2 9 MOD 4 1 3^2 9 Relational Operation Resultant 3=2 FALSE 5>1 TRUE 5=1 FALSE 7 <= 8 TRUE 9>=12 FALSE 10 < 2 TRUE 8<>8 FALSE Beginning Problem-Solving Concepts for the Computer Page 13 of 17
  • 14. Data Structures and Algorithms Operators Logical A Not A T F F T A B A AND B T T T T F F F T F F F F A B A OR B T T T T F T F T T F F F Beginning Problem-Solving Concepts for the Computer Page 14 of 17
  • 15. Data Structures and Algorithms Operators Hierarchy of Operations ( ) Reorders the hierarchy; all operations are completed within the parentheses using the same hierarchy. 1. Functions Mathematical: 2. Power 3. , MOD 4. *, / 5. +, - Relational: 6. =, <, >, <=, >=, <> Logical: 7. NOT 8. AND 9. OR Beginning Problem-Solving Concepts for the Computer Page 15 of 17
  • 16. Data Structures and Algorithms Expressions and Equations Expression @ processes data, the operands, through the use of operators @ example: LENGTH * WIDTH Equation @ stores the resultant of an expression in a memory location in the computer through the equal (=) sign @ example: AREA = LENGTH * WIDTH @ often called assignment statements because the variable on the left-hand side of the equal sign is assigned the value of the expression on the right- hand side @ the equal sign does not mean equals; instead it means replaced by or is assigned the value of Beginning Problem-Solving Concepts for the Computer Page 16 of 17
  • 17. Data Structures and Algorithms Expressions and Equations Beginning Problem-Solving Concepts for the Computer Page 17 of 17