Professional Documents
Culture Documents
Chapter 3 G8
Chapter 3 G8
Q) What is Algorithm?
1. The command Read allows the user to put information from the keyboard
2. The command Write displays a message on the screen
Ex:
1. Variable a
2. Start
3. Write “Enter a number:”
4. Read a
5. Write “Its square is”, a*a
6. End
Explanation
Exercise
Q) Write an algorithm that will ask the user to input the age and display the user’s age
1. Variable age
2. start
3. Write “enter your age”
4. Read age
5. Write “your age is:”, + age (the + sign used to create space between the strings)
6. End
Q) write the algorithm which enables the user to type the length and the width of a rectangle and then
display its parameter
1. Variable L, W
2. Start
3. Write “enter Length”
4. Read L
5. Write “enter Width”
6. Read W
7. Parameter = L * W
8. Write “parameter is:” + parameter
9. End
Writing a program:
Note to remember:
Conditions:
If instruction
1. Variable a, b
2. Start
3. Write “enter a number”
4. Read a
5. Write “enter a number”
6. Read b
7. If a > b then
8. Write “a is bigger than b”
9. Else
10. Write “b is bigger than a”
11. Endif
12. End
Code:
Displaying 2 variables are very easy, for ex: write a code that will allow you to display your name and
your age together