Vous êtes sur la page 1sur 2

Name : ____________________ Section : ____

Answer the following questions based on Algorithms.

Q.1 Read the algorithm/ pseudo code written below


NO1= 2
NO2= 5
INPUT NO3
IF NO3 > 5
TOTAL=NO1+NO2+NO3
PRODUCT=NO1*NO2
ELSE
TOTAL=NO1+NO3
PRODUCT= NO1*NO3
ENDIF
Dry run the algorithm and fill in the following trace table ( data = 3,1,-4,7,-2,9 )

SNo NO1 NO2 NO3 CONDITION TOTAL PRODUCT


1 2 5 3 FALSE 2+5=7 2*3=6
2
3
4
5
6

Q.2
INPUT X
IF X = 1 THEN PRINT “ERROR”
ELSE N = (X * X)/(1 – X)
OUTPUT N, X
ENDIF

SNO INPUT OUTPUT


1 5
2 1
3 -4
Q.3
Speed cameras read the time a vehicle passes a point (A) on the road and then reads the time it
passes a second point (B) on the same road (points A and B are 100 metres apart). The speed of
the vehicle is calculated using:
The maximum allowed speed is 100 kilometres per hour.
Write an algorithm, using pseudocode, which:
• inputs the start time and end time for vehicle that was monitored
• calculate the speed for vehicle using the formula above
• outputs the speed for vehicle and also a message if the speed exceeded 100 km/hour.

Q.4
INPUT A,B,C
IF A>B
OUTPUT A
ELSE
OUTPUT B
ENDIF
NET = 0
IF C > 10
A= B+C
B= A*10+B
NET = A+B
ENDIF
OUTPUT NET

Write the output in the following table ( the initial input values for A , B and C are
given )
SNo A B C OUTPUT
1 7 1 15
2 4 -5 9
3 2 2 2
4 23 12 11

Vous aimerez peut-être aussi