c10_ps04_sol

c10_ps04_sol - C-10 1. For X = 3 Case 1. IF x >=...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C-10 1. For X = 3 Case 1. IF x >= 0 THEN x:= x+1; ELSIF x >=1 THEN x := x + 2; END IF ; In the case above, only the x:= x+1 statement is executed and the result is 4; Case 2. IF x >= 0 THEN x := x + 1; END IF ; IF x >= 1 THEN x := x + 2; END IF ; In this case, both the x:=x+1 and x:= x+2 statements will be executed and the result is 6. 1 2 3 4 5 6 7 8 C-10 2. Package Specification Listing GNAT 3.13 p ( 20000509 ) Copyright 1992- 2000 Free Software Foundation, Inc. Checking: c:/docume~ 2 /jk/desktop/ 16070 /codeso~ 1 /my_math_package.ads (source file time stamp: 2003- 09- 24 03 : 27 : 46 ) 1 . ----------------------------------------------------------- 2 . -- Package specified to implement two arithmetic functions 3 . -- Specifier : Jayakanth Srinivasan 4 . -- Date Last Modified : 09/23/2003 5 . ----------------------------------------------------------- 6 . 7 . 8 . package My_Math_Package is 9 . subtype Menu_Choice is Integer range 1 .. 3 ; 10 . 11 . procedure Menu ( 12 . My_Menu_Choice : out Menu_Choice ); 13 . 14 . function Add ( 15 . X : Float; 16 . Y : Float ) 17 . return Float; 18 . 19 . function Multiply ( 20 . X : Integer; 21 . Y : Integer ) 22 . return Integer; 23 . end My_Math_Package; 23 lines: No errors Package Code Listing GNAT 3.13 p ( 20000509 ) Copyright 1992- 2000 Free Software Foundation, Inc. Compiling: c:/docume~ 2 /jk/desktop/ 16070 /codeso~ 1 /my_math_package.adb (source file time stamp: 2003- 09- 24 03 : 27 : 46 ) . -----------------------------------------------------------...
View Full Document

Page1 / 6

c10_ps04_sol - C-10 1. For X = 3 Case 1. IF x >=...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online