๐ก Activity Solution
๐ก Activity Solution
1๏ธโฃ What is a Variable, and why do we need it?
- A variable is a container in memory that stores data temporarily while the program runs.
- We need it to hold, update, and reuse information such as names, numbers, or results.
2๏ธโฃ What is a Constant, and why do we need it?
- A constant is a read-only container whose value cannot change once assigned.
- We need it to protect fixed values (like ฯ = 3.14) from being modified accidentally.
3๏ธโฃ What is a Memory Cell?
- A memory cell is a small storage unit in RAM that holds the binary bits of a variableโs value.
4๏ธโฃ What is an Identifier?
- An identifier is the name given to a variable or constant so the programmer can refer to it easily (e.g.,
Age,PI).
5๏ธโฃ What is a Memory Address, and what is its relation to location in memory?
- A memory address is the exact location of a memory cell inside the computerโs RAM.
- Each variable is stored at a unique address โ just like houses have unique addresses.
6๏ธโฃ Which numbering system is used to represent memory addresses?
- Memory addresses are represented in hexadecimal (base 16) form, e.g.,
0x7FFF89A2.
7๏ธโฃ Mention the primary types of variables.
- Integer (Int) โ whole numbers (e.g.,
25) - Float/Double โ decimal numbers (e.g.,
3.14) - String โ text (e.g.,
"Omar") - Boolean โ True/False (e.g.,
True)
8๏ธโฃ What are the number types, and give examples for each.
- Integer (Int): Whole numbers (e.g.,
โ10,0,150) - Float (Decimal): Numbers with fractions (e.g.,
3.5,7.25)
9๏ธโฃ What is a String, and give an example of it.
- A String stores text or characters, written between quotation marks.
Example:"Hello World"or"Mohammed".
๐ What is a Boolean, and give an example of it.
- A Boolean represents True or False values used in decisions.
- Example:
IsStudent = TrueorHasLicense = False.
0 comments