Assignment Statement in Programming
Assignment Statement in Programming
ASSIGNMENT STATEMENT
Assignment statements are used to give initial value to variables and to change
the value assigned to a variable.
The assignment statement has two parts, the Lvalue and the Rvalue. The
Lvalue refers to the variable as the storage location where the Rvalue will be
stored. The Rvalue refers to a value, which may be the result of an expression
or the content of another variable. The arrow (🡨) is used as the assignment
operator.
Days 🡨 28
Rate 🡨 500
This can be interpreted as follows, store the value 28 in the variable days and
500 in the variable rate.
The Lvalue is “salary” on the left and the Rvalue is the expression on the right,
“days*rate”. The assignment can be interpreted as, multiply the value in the
variable days by the value in the variable rate and store the result in variable
salary.
BEGIN
READ A
READ B
READ C
C🡨A
A🡨B
B🡨C
Print A, B, C
END
What would be the printed result of the variables A, B and C if 2 is entered in A, 5 entered in
B and 4 entered in C.
1. Score 🡨 75
2. Sum 🡨 220
3. Value 🡨 Sum + Score
4. Sum 🡨 Score
5. Score 🡨 Value + Sum
6. Value 🡨 Sum + Score
Answer the following questions using the lines of codes above.
Write a pseudocode algorithm to accept three numbers and find and print their sum.
We can analyze this question by finding out the Input, process and output, creating
what is called an IPO (Input, process, Output) table.
Based on the question we can arrive at the following IPO table.
START
STOP
1. Write a pseudocode algorithm to read three numbers and find their products and
average and print the sum, average and product.
2. Write a pseudocode algorithm to calculate the cost of a product given the quantity and
the unit price. The cost, quantity and unit price must be printed
3. Write a pseudocode algorithm to accept the current year and the year a person was
born. Calculate and print the age of the person.