CIT-0112-PRACTICAL
CIT-0112-PRACTICAL
Explanation:
Explanation:
3. Variables Example
Variables are storage locations for data that can change during the program’s
execution.
Explanation:
Initially, the variable score is set to 0, but it changes later to 10. Variables are
useful when you need to keep track of changing data, like a player’s score in a
game.
4. Constants Example
Constants store values that won’t change during the program’s execution.
Const PI As Double = 3.14159
Const maxAttempts As Integer = 5
Explanation:
PI holds the value of π (3.14159) and maxAttempts holds the maximum number
of login attempts allowed. These values remain fixed, and trying to change them
later in the program would cause an error.
5. Expressions Example
Expressions involve combining variables, constants, and operators to perform
calculations or logical operations.
Explanation:
This expression calculates the total price by multiplying the pricePerItem by the
quantity. The result is stored in totalPrice.
The first part checks if the userAge is greater than or equal to 18. If true, the user
is eligible to vote.
The second part checks if the user is eligible to vote and has an ID. The result is
stored in canVote. The logical And operator ensures that both conditions must be
true for the user to be able to vote.
Explanation:
Explanation: