Variables, Constants, Data Type Topicals Part 2 - O Level & IGCSE Computer Science by Inqilab Patel

Описание к видео Variables, Constants, Data Type Topicals Part 2 - O Level & IGCSE Computer Science by Inqilab Patel

Variables and constants
Variable is memory container, where a value can be stored. The values stored in a variable are changed during execution.
Like in computer game you have observed Lives and Score. At the start if game Score has a value 0, while Lives has some values like 3. During game values stored in Score are increased with each success and values stored in Lives decreases with failure. Here Lives and Score are variables, storing values, which are changed during program execution.
Constant:
Constant is memory location where a value can be stored but the stored value remaining same during execution.
Benefit of using constant: It is good practice to use constants if this makes the pseudo code more readable, as an identifier is more meaningful in many cases than a literal. It also makes the pseudo code easier to update if the value of the constant changes. The value of constant can’t be erased or changed mistakenly or willingly.
• One change can be reflected throughout the program
• The value of the constant cannot be accidentally changed

Q) Differentiate variable and constant.
Variable is memory location where a value can be stored. The values stored in a variable are changed during execution.
Constant is a memory location that stores values, but values once stored cannot be changed during program execution.


8.1.2 Data types:
Q) What are data types? Why are they needed?
A data type is a classification that specifies which type of data a variable has and what type of operations can be applied to it. Most programming languages support various types of data, including integer, real, character or string, and Boolean.

Q) What are atomic data types?
The built in data types are called Atomic Data Types. For example, Integer, Real, Boolean, String, Char, Date etc.

Q) Describe different data types with examples.
INTEGER: A whole number (without fractional part) can be positive or negative and used in calculations.
For example COUNT which never requires fractional part and may store 56, 89, 1
REAL: A number capable of containing a fractional part can be positive or negative and used in calculations.
For example Weight may contain fractional Part like 56.8, 89.0, 1.2
CHAR: A single character (may be letter, special character or number but number cannot be used in calculation).
For example, ‘A’, ‘$’, ‘5’
STRING: A sequence of alphanumeric and special characters but number cannot be used in calculation.
For example, “Abdullah”, “0300-2724734”, “House No 56 Block 2, PECHS Karachi”
BOOLEAN: A data type with two possible values
For example, TRUE and FALSE or YES or NO
DATE: To store a calendar date
For example, 16/04/2010

Комментарии

Информация по комментариям в разработке