DISPLAYING THE VALUE OR CONTENTS OF VARIABLES
The write or writeln statement displays the value
of variables on the console screen. To print text, enclose inside
single quotes. To display the value of a variable, do NOT enclose
using single quotes, eg, the following program displays the content
of each of the variables declared.
program DISPLAYVARIABLES (output); var number1 : integer; letter : char; money : real; begin number1 := 23; letter := 'W'; money := 23.73; writeln('number1 = ', number1 ); writeln('letter = ', letter ); writeln('money = ', money ) end.The display output from the above program will be,
number1 = 23 letter = W money = 2.3730000000E+01
Firstletter := A; ___________________________________ StartCount:= Initial := 0; ___________________________________ Taxrate := 5%; ___________________________________ Total := 5 plus 7; ___________________________________ Effeciency := .35; ___________________________________ Click here for answerCLASS EXERCISE
program EXERCISE1 (output); var a, b : integer; c : real; begin a := 1; b := 5; c := 1.20; writeln('A = ', a + 3 ); writeln('B = ', b - 2 ); writeln('C = ', c / 2 ) end. Click here for answer
PROGRAM TWO
Write a program to calculate the gross pay for a worker named FRED
given that FRED worked 40 hours at $2.90 per hour.