0% found this document useful (0 votes)
2 views

Intro to Programming 2

The document is an introduction to programming that includes questions on algorithms, control structures, flowcharts, and problem-solving steps. It features sections for defining concepts, coding exercises, and pseudocode tasks. Additionally, it includes a practical application involving temperature input and cost calculations for taxi journeys.

Uploaded by

PCC, IT Director
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Intro to Programming 2

The document is an introduction to programming that includes questions on algorithms, control structures, flowcharts, and problem-solving steps. It features sections for defining concepts, coding exercises, and pseudocode tasks. Additionally, it includes a practical application involving temperature input and cost calculations for taxi journeys.

Uploaded by

PCC, IT Director
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Introduction to Programming

SECTION A – Do all questions in this section.

1. State clearly the definition of an algorithm.


[2 marks]
2. What is the difference between a constant and a variable and give ONE real life
example for each.
[3
marks]
3. The diagram below represents a Flowchart.
a. Identify the Flowchart symbols labeled A,B,C,D, E and F.
[3
marks]
b. Which symbol represents the initialization of a variable or a constant?
[1
mark]
c. The segment between C-F-C represents which of the control structures.
[1 mark]

4. What is the difference between the following pairs of control structures? Write a
simple code to illustrate the differences.
a. IF-THEN and IF-THEN-ELSE
b. FOR loops and WHILE loops [4 marks]
5. List any four steps that are involved in problem-solving [2 marks]
6. Give the truth table (decision table) of the AND and OR operator. [4 marks]

7. Determine if the following statements are TRUE or FALSE given:


a = 4, b = 0, c = 8.
a. If( a > b AND c < a)
b. If(c > a OR b > c) [2 marks]

SECTION B

Compulsory

8. Write a program to input the maximum and minimum temperature of a day. If the
maximum temperature is greater than 30 degrees celcius, output the message “It
was a hot day!”. The program should also output the difference in the maximum
and minimum temperature. [5 marks]

SECTION C
Answer any TWO questions

9. Write a pseudocode to read in an integer value N. The pseudocode must print


each integer from 1 to N and its sum. [10 marks]

10. Write a pseudocode that reads two values which are then stored in A and B. If A
is larger than B it should divide A by B and print the results else it should print “A
is not larger. The program must continue to read two more values and terminate
only if the second value is equal to zero. [10 marks]
11. The rate to travel in Kingston is $100 per km travelling by a taxi. A journey
involves two trips. Use the algorithm outline in the flowchart below to write the
corresponding pseudocode. Note DO NOT rewrite the words in the pseudocode.
[1O
marks]

Start

Get the distance to shop in km

Find cost of trip to shop

Get the distance to office in km

Find cost of trip to office

Find total cost of transportation

If total
cost is No
greater
than or
equal to
$500

Yes
Calculate a 10% discount for the
Add $50 to the total cost
passenger

Print what the passenger pays for


the journey

Stop

You might also like