Friday, January 16, 2026

User Defined Data Type

 What is meant by user defined datatype?

  • Derived from one or more existing datatype.
  • Used to extend the built-in data types.
  • To meet programmer's requirement.
Explain why user defined datatype are necessary?
  • No suitable data type is provided by the language used.
  • If a programmer needs specific datatype.
  • that meets programmer's requirements.

Data Types

Non-composite Datatype: A single datatype that does not refer to another data type. 
(Enumerated, Pointer, Real, String, Char, Boolean, Integer)
Composite Datatype: A data type that refers to other data types. Data type constructed from another data type.
Record: Collection of related items which may have different data types.
List: An indexed collection that can have different data types.
Set: Supports mathematical operations.
Array: Collection of items with the same data type.
Class: Gives properties and methods for an object.

Enumerated Data Type

  • Non-composite
  • Defined by a given list of all possible values
  • In an order
Pseudocode to Declare an Enumerated Data Type
Type ____ = ( __, __)

Q. Declare a variable currentmonth of data type Months.
DECLARE Currentmonth: Months

Q. Declare a variable nextmonth and print nextmonth.
DECLARE Nextmonth: Months
Nextmonth <-- Currentmonth + 1
PRINT Nextmonth

Pointer Data Type

  • Non-composite
  • Used to reference a memory location.
^ : This symbol represents pointer.
@ : This symbol represents, the address is required not the value.

Pseudocode to Declare Pointer Data Type
Type ___ = ^___

Dereferencing: You have the address and you want the value on that address.
Num2 <--- myintpointer^

Records Data Type

  • Composite Data type
  • Group of multiple data types
Pseudocode to Create a Record Data Type
TYPE
         DECLARE ____:____
         DECLARE ____:_____
ENDTYPE

Declaring a Range
DECLARE Number: 0, 1, 2, 3 ....
DECLARE Name: ("Alizan", "Junior Tanol", "Samona")

Specific Data Type in Array
DECLARE Names: ARRAY[1:3] OF STRING
DECLARE Num: ARRAY[1:3] OF ["1", "2", "3"]

Arrays --> Multiple --> Specific Data types with Quotation Marks
Variable --> Single --> Enumerated without Quotation Marks

pH Scale, Importance, and Indicators

pH Scale  

- The pH scale ranges from 0 to 14 and is used to determine the strength of acids and bases.  

- Strong acids: pH 1–4  

- Weak acids: pH 5–6  

- Neutral: pH 7  

- Weak bases/alkalis: pH 8–10  

- Strong bases/alkalis: pH 11–14  

Importance of pH  

Maintaining the correct pH is essential for proper functioning of systems:  

- Small intestine: Maintained at an alkaline medium for effective digestion.  

- Soil: Optimal pH for plant growth is 7–8.  

  - If soil becomes too acidic, it is treated with slaked lime (Ca(OH)₂) to neutralize acidity.  

Indicators  

- Definition: Indicators are weak organic acids or bases that change color depending on the pH of the solution.  

- Application: Used to determine whether a substance is acidic or alkaline.  

Examples of Indicators:  

- Methyl Orange  

- Phenolphthalein  

- Litmus  

- Methyl Red  

- Congo Red  

Color Changes:  

- Methyl Orange:  

  - Acidic medium → Red/Pink  

  - Basic medium → Yellow  

- Phenolphthalein:  

  - Acidic medium → Colorless  

  - Basic medium → Red/Pink  

Definitions  

- pH:  

  pH = -log H+ 

  Defined as the negative logarithm of the hydrogen ion (or hydronium ion) concentration of a solution.  

- pOH:  

  pOH = -log OH-

  Defined as the negative logarithm of the hydroxide ion concentration of a solution.  

Physical Properties and Uses of Bases

Physical Properties of Bases  

- Litmus Test: Bases/alkalis turn red litmus paper blue.  

- Taste: Bases are bitter.  

- Touch: Alkalis feel soapy or slippery to touch.  

- Corrosiveness: Concentrated alkalis are corrosive and can cause burns.  

Uses of Bases  

1. Calcium Hydroxide (Ca(OH)₂): Used in making mortar, cement, and plaster.  

2. Sodium Hydroxide (NaOH): Essential in the production of soaps.  

3. Bases are used in manufacturing rayon and paper.  

4. Employed in softening hard water.  

5. Magnesium Hydroxide (Mg(OH)₂):  

   - Used in toothpaste.  

   - Acts as a laxative and antacid (commonly called milk of magnesia when dissolved in water).  

6. Bases are used in glassmaking.  

Indicator Color Changes in Acids and Bases

Indicator Color Changes in Acid vs Alkali

Indicator In Acid (Low pH) In Alkali (High pH)
Phenolphthalein Colorless Pink
Methyl Orange Red Yellow
Methyl Red Red Yellow
Methyl Violet Yellow Violet
Methylene Blue Red Blue
Bromothymol Blue Yellow Blue
Bromocresol Green Yellow Blue-green
Thymol Blue Red Yellow (first transition), Blue (second transition at higher pH)
Litmus Red Blue

Indicators and Precautions in Volumetric Analysis

Indicators  

- Definition: Indicators are organic compounds, usually weak acids or bases, that change color according to the pH of the medium.  

- Application: Widely used in titration experiments to signal the endpoint of a reaction.  

Examples of Indicators:  

- Phenolphthalein  

- Methyl Orange  

- Methyl Red  

- Methyl Violet  

- Methylene Blue  

- Bromothymol Blue  

- Bromocresol Green  

- Thymol Blue  

- Litmus  

Precautions in Volumetric Analysis  

To ensure accuracy and reliability in titration experiments, the following precautions must be observed:  

1. Preparation of Apparatus  

   - Rinse burette with distilled water, then with the acid it will contain.  

   - Rinse pipette with distilled water, then with the base it will contain.  

   - Rinse conical flasks and beakers with distilled water.  

   - Ensure the burette is not leaking.  

2. Measurement Accuracy  

   - Take burette and pipette readings at eye level to avoid parallax error.  

   - Record values to two decimal places.  

3. Indicator Use  

   - Add only 2–3 drops of indicator to the base before titration.  

   - Do not leave the funnel on the burette during titration.  

4. Handling Pipette  

   - Do not blow out the last drop of liquid.  

   - Instead, touch the tip of the pipette to the wall of the conical flask to release it.  

5. Calculation and Accuracy  

   - Use the average volume of acid for calculations.  

   - Avoid air bubbles when filling the pipette or burette.  

Ionic Size

Cations  

- Definition: Cations are formed when an atom loses electrons.  

- Effect on Size:  

  - Loss of electrons often leads to loss of an entire shell.  

  - The effective nuclear charge on the remaining valence electrons becomes greater.  

  - As a result, cations have smaller ionic radii compared to their corresponding atomic radii.  

Anions  

- Definition: Anions are formed when an atom gains electrons.  

- Effect on Size:  

  - Addition of electrons increases electron‑electron repulsion.  

  - This can expand the electron cloud and sometimes add to the number of shells.  

  - Consequently, anions have larger ionic radii compared to their corresponding atomic radii.  

Key Insight  

- Cations → Smaller than atoms (due to electron loss and stronger nuclear pull).  

- Anions → Larger than atoms (due to electron gain and increased repulsion).  


Kinetic Theory of Gases

The kinetic theory of gases explains the physical behavior of gases based on certain assumptions. It applies to ideal (or perfect) gases, which are theoretical models used to simplify gas behavior.  

Postulates of the Kinetic Theory of Gases  

1. Random Motion  

   - Gas molecules move randomly in straight lines, colliding with each other and with the walls of the container.  

2. Elastic Collisions  

   - Collisions between gas molecules are perfectly elastic, meaning no energy is lost during collisions.  

3. Negligible Volume  

   - The actual volume occupied by gas molecules is negligible compared to the volume of the container.  

4. Negligible Forces of Attraction  

   - The forces of attraction between gas molecules are negligible, allowing them to move independently.  

5. Temperature and Kinetic Energy  

   - The temperature of a gas is directly proportional to the average kinetic energy of its particles.  

Key Insight  

- This theory provides the foundation for understanding gas laws (Boyle’s, Charles’s, and Avogadro’s laws).  

- Real gases deviate slightly from these assumptions under high pressure or low temperature, but the model remains a powerful tool for predicting gas behavior.  

User Defined Data Type

  What is meant by user defined datatype? Derived from one or more existing datatype. Used to extend the built-in data types. To meet progra...