110 likes | 211 Views
Homework 4 revision. For this part: Explain how you could do this problem if the social security number is read instead as a longint. You can use the digits in reverse order. I realized you have not learned how to do it as stated yet. Don’t do the program - just explain.
E N D
Homework 4 revision • For this part: • Explain how you could do this problem if the social security number is read instead as a longint. • You can use the digits in reverse order. I realized you have not learned how to do it as stated yet. • Don’t do the program - just explain
HW 4 revision (con’t) • If ss# is 987654321 your output would be:9:999999999 8:88888888 7:7777777 6:666666 5:55555 4:4444 3:333 2:22 1:1
Standard Functions: arithmetic • Sqr(x): squares x • sqrt(x): positive square root of x • abs(x): absolute value of x • exp(x): raises e to x power • ln(x): log of x to base e • cos(x): Cosine of x • sin(x): Sine of x • arctan(x): Arctangent of x
More standard functions • Transfer functions (real to integer) • Round(x) rounds x to the closest integer • trunc (x) drops the part of x to the right of the decimal. • Boolean functions • odd (x) returns TRUE if x is odd or FALSE if x is not • we will learn others later
Turbo Pascal non-standard functions • Pi: the value of pi (note: no arguments) • upcase(L): returns uppercase for a lowercase letter L. For any other character it returns the same character. • Frac(x): returns part to the right of the decimal • int(x): returns part to the left of the decimal • random(N): returns random integer between 0 and N-1 • random: returns random real between 0 & 1
Midterm topics • Variables • types • integers • reals • boolean • character • strings • rules for naming • garbage values
Midterm topics (con’t) • Arithmetic operators • integers • reals • precedence • formatting output - all types • reading data • buffer • all types
Midterm topics (con’t) • Units • compiler • loops • FOR TO • FOR DOWNTO • nested • ordinal types - all topics
Midterm topics (con’t) • Programming • any topic covered in • class • homework • chapters 1-5 • functions