Paper 2 at a glance
Data types: determine the type of data and operations
   Algorithm: Step by step design of a solution                 can be performed on a data item.
   Pseudo code: textual representation of algorithm              1. INTEGER: + or - whole numbers, for calculation. E.g.
   Flowchart: graphical representation of algorithm                 Count = 25, NoOfStudents=100
   Variable: A memory location used to store values that can     2. REAL: + or - Numbers with fractional part, for
   be changed during program execution                              calculation. Price=78.90
   Constant: A memory location used to store values that         3. CAHR: a single character (symbol, letter or digit , but
   cannot be changed during program execution                       digit is not for calculation) Section='A', Gender = 'F'
     SEQUENCE: All statement are executed in order               4. STRING: a series of alpha numeric and symbolic
     Step   Example                                                 characters, but numbers are not for calculation.
                                                                    Name="Abdullah", Address="H # 65/2, Street #22",
     Input  INPUT Price, Quantity                                   Tel="0300-2737146"
     Process Amount  Price * Quantity                           5. BOOLEAN: may store Yes or No, True or False, 1 or 0.
     OUTPUT PRINT Amount                                         6. DATE: May store calendar date like 15/12/2021
                                                                       REPETITION / LOOP / ITERATION:
                                                  To execute a set of statements several time
                                                  FOR … TO … NEXT         WHILE … ENDWHILE REPEAT … UNTIL
SELECTION/CONDITIONAL:                            Count-Controlled Loop Pre-Condition Loop Post-Condition Loop
To determine program flow path on the basis of    When number of        Condition is given at Condition is given at the
given condition                                   repetition is already the beginning         end
IF Selection       CASE Selection                 given
1 or 2 outcomes    Several outcomes               Input data of 30       Input marks, reject if Input weight of
IF Marks >=50      CASE OF Marks                  students               marks is more than passengers in a lift, stop
  THEN              >=90: Grade  "A*"                                   100 and input again input if total weight is
    Result "Pass" >=80: Grade  "A"                                                            more than 600
ELSE                >=70: Grade  "B"             FOR Count  1 TO 30 INPUT Marks               Total  0
    Result  "Fail" >=60: Grade  "C"               INPUT Marks          WHILE Marks>100        REPEAT
ENDIF               >=50: Grade  "D"             NEXT Count               PRINT "Error!"         INPUT Weight
                    >=40: Grade  "E"                                      INPUT Marks            Total  Total + Weight
                    OTHERWISE: Grade "U"                                END WHILE              UNTIL Total >=600
                   ENDCASE
                                                                         Executes when          Executes when condition
                    Make code shorter, more                              condition is true      is false
                    efficient
                                                  Will be executed a set May not be executed    Will be executed at least
                                                  number of times        even once              once
   Count  0
   Count  Count + 1                                                    Highest  0
                                                                        IF Num > Highest THEN Highest Num
   Total  0
   Total  Total + Num
                                                                         Lowest  100
                                                                         IF Num < Lowest THEN Lowest Num
 INPUT "Enter data to search ", SearchData
 Found = FALSE                                                       FOR Round = 1 TO (MaxIndex-1)
 Index = 0                                                              FOR Index = 1 TO (MaxIndex-Round)
 WHILE Index< MaxIndex AND Found=FALSE                                     IF Data[Index] > Data[Index+1] THEN
     IF Data[Index] = SearchData THEN                                         Temp = Data[Index]
         Found=TRUE                                                           Data[Index] = Data[Index+1]
         OUTPUT "Found at ", Index                                            Data[Index+1] = Temp
     ELSE                                                                  ENDIF
         Index = Index + 1                                              NEXT Index
     ENDIF                                                           NEXT Round
 ENDWHILE
 IF Found=FALSE THEN OUTPUT "Not Found"
                                           Main Page 1
ARRAYS: A data structure used to store several elements
of same data types                                    Flowchart: Graphical representation
DECLARE Num[1:5] OF STRING                            of algorithm
FOR Count = 1 TO 5                                                                              Start/End
  INPUT Num[Count]
NEXT Count                                                                                      Process
                                                                                                Input/Output
                                                                                                Decision
                                                                                                Procedure/
                                                                                                Function
                                                                                                Flow Arrow
                                               String Handling Functions
                                               LENGTH       To return number of characters including space in a string
                                                            For Example:
                                                                  Name="Inqilab Patel"
                                                                  LENGTH(Name)       will return 13 including space
                                               SUBSTRING To Return part of string for example:
                                                           SUBSTRING(string, startposition, number of characters)
                                                           SUBSTRING(Name,1,7)            will return "Inqilab"
                                                           SUBSTRING(Name, 9, 5)          will return "Patel"
                                               UCASE         To Return string in upper case, for example:
                                                                UCASE(Name)                will return "INQILAB PATEL"
                                               LCASE         To return string in small case, for example:
                                                                LCASE(Name)               will return "inqilab patel"
                                               Library routines (built-in functions)
                                               ROUND         To return number with number of places decimals
                                                             ROUND(Number, number of decimal places)
                                                                   ROUND(76.2389, 2)          will return 76.24
                                                                   ROUND(76.2342, 0)          will return 76
  RollNo Name     Class Marks Result
                                               RANDOM       To return a random number between 0 and 1 inclusive
  101    Abdullah OL    92    Pass                             ROUND( )
  102    Muzna AS       92    Pass                                  will return a random number between 0 and 1
  103    Laiba     AS     93     Pass                          ROUND(RANDOM()*20)
                                                                   will return a number between 0 and 20
  104    Muzna     OL     85     Pass
                                          Fields: a piece of data organised in columns
                                          Records: collection of all related fields, organised in rows
                                          Primary key: a field that contains unique data items
  SQL script: to display all records:     Fields Data types       To display roll number of name of
  SELECT ALL                                                      students in AS:
                                          RollNo Integer
  FROM STUDENTS                                                   SELECT RollNo, Name
                                          Name Text               FROM STUDENTS
  To display all name and marks in        Marks real              WHERE Class = "AS"
  ascending order of marks :            To count how many students are in OL:
  SELECT Name, Marks                    SELECT COUNT(RollNo)
  FROM Marks                            FROM Students
  ORDER BY Marks ASC                    WHERE Class = "AS"
                                        Main Page 2