Title | Pascal Control Structures |
---|---|
Author | Daniel Kaba |
Course | Programming |
Institution | University of Northampton |
Pages | 37 |
File Size | 468 KB |
File Type | |
Total Downloads | 1 |
Total Views | 144 |
Lectures Notes...
!!"# •
"
•
"
•
$%&%'
!( ! !
)
*
+
,
-
$!
+)
,
-)
$
-+
.*
Control Structures-Selection
1
& !!(
/0 #1 22-2(2-22-22-232 " * ! " ! "#$%&'#()" ! !&4!0*.
Control Structures-Selection
2
*+ %&$)+"#() -5 + )+, " 678'( '9&5:; 'A:;
). )+/ 9&5:; B'
C/#&;
)0%
>9?*!.#?:;
'9C/:;
&9C,5/)7:!0*.
>9C?&(?/:;
) .
Control Structures-Selection
3
#$&!4*" !The &D!D* 2D292&2de and the "Else" side). !&4!0*.4*$"*
9 : *+ &- +! -5 + * -5 +;
Control Structures-Selection
4
)+, 9&5:; 9C?&(?/:
>9C?&.5!(?/:;
) . )+/ $E&9&5:; 9C?&$!?/:
>9/?&.5!(?C:;
) .
Control Structures-Selection
5
)+1 $9&5:; 9?!,&?,:; ) . Control Structures-Selection
6
#$%3" > #
&,# 9.:& )+$"!%3 &*+4 &- G+! - G+ *&- H+! - H+ *&- +! - + * - +; .*&222&2 2*2.*& 2 G2 *&; 2 G22 H2D 2 H2 *& *&! Control Structures-Selection
7
* &* & )+4 &+)67! >9?@A: *&+)I7! >9?@(A: *&)J7! >9?@A: *&+)H7! >9?@A: * >9?@*A:; # A !%" # -!* +& - G+#-G+; - H+#-H+; 4 ) -+ )5 !#! * 9: ! *! * )+4 )& 67G77#>9?@A: I7KL#>9?@(A: J7ML>9?@A: H7NL>9?@A: 7GL >9?@*A: * >9?&@A:; ). Control Structures-Selection
8
#+667*338 34 & )+ - +O P GG7G77 2/222 - +- + GL 2222 9: MH7HLJN *C,$*"
Control Structures-Selection
9
))#%#%%#)#%#9#9)$" & $ G >4 H '41 N #8' &D9 !'1*: !Q *+ >9* : "; & #'9 &D9 ! !'1*:!'4 *+ ' "; 19* :;
Control Structures-Selection
10
& 'D1
FOR ….Do Loop A for loop executes a section of code for a fixed number of times. The for loop is used you already know the number of times a section of code is going to be executed. Syntax FOR Loop Control Var := Initial Value TO Final Value DO Statements; OR FOR Loop Control Var := Final Value DOWNTO Initial Value DO Statements; Example
Control Structures-Selection
11
) 9) &9#% ) 9) D % $:8" & 9 : 0%3$%;"5 @ ! @B '5*1'* '5*1'* )0%
, ;
) .AG6 %9# 9#9#& #%A &'%' U !>%> %3* '9'OGP:; '9"OHP:; '9@ONP:; *3*$3" >9'OGP:; >9"OHP:;
Control Structures-Selection
22
)+ E9&5:; 9?A:;
>9?GA"OGP#J:;
>9?HA"OHP#J:;
>9?NA"ONP#J:;
>9?JA"OJP#J:;
>9?MA"OMP#J:;
) .9??& "O& P#J:;
) .#"
& G& H#&;
,#(;
=
>9?*!>A:;'9>:;
& G#)G;
& H#)59O7P:;9>?&A:
>9>?&.5!A:;
) .=
B#)7; O P:5
?A?A?A?A?A#B#)BSG;
?A?*A?&A?5A?1A#B#)BSG;
Control Structures-Selection
26
*;
*;
9"OHHP:; )?) > G H N H J I N I L J 6 GH M G7 GM I GH G6 HEEE9&5:; - !#''/OGIGMP5&; /#&; >9?!,!A:; #)G!I ( #)G!M ( #)R; 9#J:; OP#); *; >; *; ).
Control Structures-Selection
J 6 GH GI H7 HJ
M H7 GM H7 HM N7
29
)+/5 !1 J I H 7 M N 6 K L 7 GG GN ># : : &Q : " 3/ * B' .#''/OGNGJP5&; %C373A ( .OGGP#)J; .OGHP#)I; .OGNP#)H; .OGJP#)7; .OHGP#)M; .OHHP#)N; .OHNP#)6; .OHJP#)K; .ONGP#)L; .ONHP#)7; .ONNP#)GG; .ONJP#)GN; *; ! )(%0 #%0 #%0 "" ! #%0#)(%@9) " !" " Control Structures-Selection
30
! # : (" : &" : "" : T" : "" 9)# !! U (8%:! ! ! ! )+, B$%;"5 - #''/OGIP5&; !U#&; >9?* *?:; #)G!I9?* *?:; #)G!I9?!"$A:; #)G!I >9OP:; ). )(%0 " & 5 !# G $%"" H (" %))@9)#%)( & & & Control Structures-Selection
34
)+ $" *9M7J7KMMML7JM:> MM B$%;"5 - #''/OGIP5&; &$#&; #(; #); >9?* *?:; #)G!I9?!&#?$: * >9?!.5!A:; ). )+/*& B$%;"5 #A) $)''/OGIP5&; - #$; &$#&; #(; &$*4*5+4%"4%5 #)G!I ( &9OP) :!9R,R: ( $#); Control Structures-Selection
35
#)!; *; *; )59?!.5!A:; ). %A)( !(VW& & (:%#:D ! &9:! ...