Friday, October 19, 2018

GCE(O/L) Past Paper question and answer Flow chart

A teacher of a class of 35 students obtains the student preference to travel either by train or bus on their annual trip. The following flow chart with missing terms labelled A to E represents this scenario. Write down the appropriate terms for the labels A to E. (Any variable names that are used in your answer must be exactly as given in the question.)

GCE(O/L) Past Paper Question

Answer

A   -  0                    (bus_count=0)
B   -  35                   (student_count < 35)
C   -  train_count          (train_count=train_count + 1)
D   -  train_count          (train_count > bus_count)
E   -  tour by bus


Note
Pascal program is given for the above algorithm for extra knowledge.


program findTravelPreference;

var
  total_student:integer;
  student_count:integer;
  train_count:integer;
  bus_count:integer;
  student_preference:String;
begin
  total_student:=2;
  student_count:=0;
  train_count:=0;
  bus_count:=0;
  while student_count < 35 do
  begin
    writeln('Enter your prefernce Bus/Train');
    readln(student_preference);
    if student_preference='Bus' then
       bus_count:=bus_count + 1
    else
        train_count:=train_count +1;
    student_count:=student_count+1;
  end;
  if train_count > bus_count then
     writeln('tour by train')
  else
      writeln('tour by bus');
  readln;
end.
               



No comments:

Post a Comment