Intro to Programming Review Dry Run Taking Names

  • Slides: 10
Download presentation
Intro to Programming Review Dry Run Taking Names Online time Math is Good

Intro to Programming Review Dry Run Taking Names Online time Math is Good

Learning Objectives • Review: What makes a good variable. • Be able to Dry

Learning Objectives • Review: What makes a good variable. • Be able to Dry run a program that includes math operations and output • Understand how input names into a program. • Be able to develop a program in Pascal. • If time. A little more math review and a letting Pascal do the math for you.

Which are valid variable names? Which are good variable names? 1. 2. 3. 4.

Which are valid variable names? Which are good variable names? 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Yo 3 daysleft Summer time X Q Top Score Address Begin Writeln End X 1 X^2 What? Number from 1 to 13 and write valid/invalid and good/bad.

{Mr. Smith's Sample Program} {Dry Run #2} {5 -20 -2015} program Dry. Run. Test;

{Mr. Smith's Sample Program} {Dry Run #2} {5 -20 -2015} program Dry. Run. Test; uses crt; var a, b, c: integer; begin clrscr; a: = 20; b: = 16; c: = a+b; writeln(a, b, c); b: = c – 2*(a+b) -6; a: = c + b; writeln(a, b, c); end. Dry run 1 (What do you think the following program does? )

Getting Names Program sample 2; var name: string; begin writeln(‘Please enter your name. ’);

Getting Names Program sample 2; var name: string; begin writeln(‘Please enter your name. ’); readln(name); writeln(‘Hello ‘, name, ’ welcome back!’); readln; end.

Your program • Write a program that will display your home address as it

Your program • Write a program that will display your home address as it would on an envelope. – Push: Let the user enter some or all of the information, and have your program format it. • Write a program that shows a poem or song. Can be an original work. Include space as appropriate. – Push: Look up for. . do, or repeat. . until to have your program repeat the song several times. • Write a mad-lib program – Have the user enter at least 4 pieces of information. • Noun, Adverb (honestly), Adjective (messy), Verb, Geographical location, … – The computer will generate the mad-lib

Math + x ÷ () Pascal + * / () Code Example Ans: =

Math + x ÷ () Pascal + * / () Code Example Ans: = first+second; Ans: = second – first; Ans : = first * second; Ans : = first / second Ans : = (first + 2)/second; π PI Ans : = PI; 52 √ sqr Sqrt() Ans : = sqr(first); Ans: = sqrt(first);

You turn: What is the result of the following? Expression Answer 2+ 12 5*(8

You turn: What is the result of the following? Expression Answer 2+ 12 5*(8 -15) 5 + 6*3 6 + 4/2 – 8 (6+4)/(2 -8) Sqrt(9) Sqrt(4*4 + 9) Sqrt(sqr(3) + sqr(4)) Type

Fix the following Fix 5 -20. pas in the assignments folder Open it in

Fix the following Fix 5 -20. pas in the assignments folder Open it in Pascal, save it to your documents then fix it. prograhm Fix it 1 {Finding the average of two numbers) Number 1, number 2, The average: integers. start writeln("Please enter two numbers) readline(17, 13) number 1+number 2/2 = average Show The average of 17 and 13 is average stop

Write a program for one of the following • Extension: Look up If. .

Write a program for one of the following • Extension: Look up If. . then to check if the sides entered actually do make a triangle.