PROG6.PAS 896 B

123456789101112131415161718192021222324252627282930313233
  1. PROGRAM PROG6;
  2. {$U+ Copyright (C), 1985 by Lyle Faurot. All rights reserved.
  3. New Topics: IF statement
  4. Conditions used with IF
  5. }
  6. VAR
  7. Have, Want : Integer;
  8. BEGIN
  9. Write('How many computers do you own? ');
  10. ReadLn(Have);
  11. Write('How many computers would you like? ');
  12. ReadLn(Want);
  13. WriteLn;
  14. If Have = 0 {One-way IF .. THEN }
  15. THEN
  16. WriteLn('No computer! Give me a call at 123-4567.');
  17. If Have >= Want {Two-way IF .. THEN .. ELSE }
  18. THEN
  19. WriteLn('Congratulations! Happy Computing!')
  20. ELSE
  21. WriteLn('Sorry about that!');
  22. If (Want - Have) > 2 {Integer expression as part of condition }
  23. THEN
  24. WriteLn('(Aren''t you a little greedy?)');
  25. END.
  26.