More complicated program to read in and print back out info: program snoop; var firstname, city:string; begin writeln('What is your first name?'); readln(firstname); writeln('What city do you live in?'); readln(city); writeln(firstname); writeln('lives in'); writeln(city); writeln('What city were you born in?'); readln(city); writeln(firstname); writeln('was born in'); writeln(city); readln; end. Note reuse of variabe city, note destinction between 'city' and city. Sample output: >What is your first name? What city do you live in? Dietolf >lives in >Hillsborough >What city were you born in? Dietolf >was born in >Berlin ------------------------------------------------------------------------ Simplified car diagnosis program (first level of decision tree only): program cara; var response: string; begin writeln('Was your car running just before this?'); readln(response); if response = 'yes' then begin writeln('Fuel problems are likely.'); writeln('We will have to look at the gas gauge.'); end else begin writeln('Electrical problems seem likely.'); writeln('Let us check out the battery first.'); end; readln; end. Sample output: >Was your car running just before this? Electrical problems seem likely. >Let us check out the battery first. ------------------------------------------------------------------------ Car diagnosis program (both levels of the decision tree): program carb; var response: string; begin writeln('Was your car running just before this?'); readln(response); if response = 'yes' then begin writeln('Fuel problems are likely.'); writeln('Is gas gauge on empty?'); readlin(response); if response = 'yes' then begin writeln('Get gas.'); end else begin writeln('Call a tow truck.'); end; end else begin writeln('Electrical problems seem likely.'); writeln('Does engine crank?'); readlin(response); if response = 'yes' then begin writeln('Check out gas.'); end else begin writeln('Check out battery'); end; end; readln; end. Sample output: >Was your car running just before this? Electrical problems seem likely. >Does engine crank? Check out battery ------------------------------------------------------------------------ Program fragment to illustrate the use of IF-THEN. Use for multiway decisions: readln(color); if color = 'green' then writeln('Keep going.'); if color = 'yellow' then writeln('You need to go faster!'); if color = 'red' then writeln('I guess you should stop.');