Input and Output
Output Prompt: –A message displayed to the user indicating what they are to enter. Should be clear and exact on what you want. write: –used for output, no return writeln: –has a return for next line to be printed on CRT.
Input readln –u–used to get the information from the user into a variable. –Y–YOU MUST PUT THE VARIABLE NAME!!! readln(name); –C–Can be used without a variable to hold the output on the screen. readln;
Formatting Output In a writeln you can combine literals and variables by seperating them by commas. –writeln(‘Hi ’, name, ’, it is nice to meet you!’);
More on Formatting You can increase the number of spaces that a variable uses. –writeln(‘Name’:10, ‘Date’:10); – Name Date For real numbers you can also state the number of places after the decimal. –writeln(‘Ave=‘, ave:5:1); –Ave= 95.6
Assignment Statement := is read “becomes equal to”. variable := expression. –ave := (num1+num2)/2; operators follow math order of operations –(+ = plus), (- = minus), (* = multiply), –(/= division), (div=quotient of integer division), –(mod=remainder of integer division)
Assignment Questions for chapter 4 are due Friday. Lab test on Friday 1/2 period #6 on page 110. Written Test on Friday ch 3 and 4 Program due next Friday –Do the 5 steps for the following assignment. –Number 4 on page 111. Be sure to be colorful and creative with your output. –Ask the user their name and include a title on the report. Like Luci’s Calorie Counter.