diff --git a/prada2012/ch02/questions.txt b/prada2012/ch02/questions.txt new file mode 100644 index 0000000..22bfe53 --- /dev/null +++ b/prada2012/ch02/questions.txt @@ -0,0 +1,34 @@ +Exercise 2.4 + +1. Write statements to copy the array Next into the array Pascal. + + -- Question: is there a 'Length' function call? + for I in 0 .. 10 loop + Pascal(I) := Next(I); + end loop; + +2. Write a nested loop to compute all the rows of Pascal's triangle in + the two-dimensional array Pascal2. + + for Row in 1 .. 10 loop + Pascal2(Row, 0) := 1 + for Col in 1 .. Row-1 loop + Pascal2(Row, Col) := Pascal2(Row-1, Col-1) + Pascal2(Row-1, Col); + end loop; + Pascal2(Row, Row) = 1; + end loop; + +3. Declare a type Month_Name and then declare a type Date with components + giving the day, month, and year. Then, declare a variable Today and assign + Queen Victoria's date of birth to it (or your own). + + type Month_Name is range 1 .. 12; + type Date is + record + Day: Integer; -- maybe restrict to maximum day? + Month: Month_Name; + Year: Integer; + end record; + Today: Date; + Today := (Day => 14, Month_Name => 9, Year => 2019); +