Cú pháp 1
Fortodo
Y nghĩa:
do!
"#$
%&'()*%+!
Cú pháp 2:
ForDownTodo
nghĩa:
",-% .,'/
+0123
%&'()4%+!
5
6
!"#$%&
6
' (
)!*"#$%&
6
+,,- ./ +,,0.
12131213"(!"#$%
40"#$%&
7
!"#$
% !&'()'*+%(,-.
/01
$ i,s,n: integer;
23
write(‘Nhap n = ’); readln(n);
4 i:=1 n
4 odd(i) 3 s:=s+i;
writeln(‘s = ’, s:4); readln;
5
8
V d 2.
V d 2.
Vi!t chương tr%nh tnh
Vi!t chương tr%nh tnh
6$1*7
$89/:37
93$7
23
;3<= >?@73$<@7
9>;
9> A<BCD @7
;3<=E$ 9?8 99F@7
3$7
5
9
:
6$1*G/7
$89/:37
93$7
23
;3<= >?@73$<@7
9>
9> A<BC<HD@D @7
;3<=E$ 9?8 99F@7
3$7
5
I/JK+L $9
I/JK+L $9
5;5 5;58 5;7: 5;8< 5;9= 5;:5 5;>8 5;<: 5;?<
7;7 7;5: 7;7? 7;85 7;99 7;:< 7;>5 7;<58 7;?5>
8;8 8;5< 8;75 8;8: 8;95= 8;:58 8;>5< 8;<75 8;?7:
9;9 9;5= 9;79 9;85= 9;959 9;:7= 9;>79 9;<8= 9;?89
:;: :;55 :;7< :;858 :;97= :;:7: :;>85 :;<8< :;?98
>;> >;58 >;75 >;85< >;979 >;:85 >;>8? >;<9: >;?:7
<;< <;5: <;758 <;875 <;98= <;:8< <;>9: <;<:8 <;?>5
?;? ?;5< ?;75> ?;87: ?;989 ?;:98 ?;>:7 ?;<>5 ?;?<
>
*$8M9/:37
/3
;3<=2$9?@
9>
/3
M9>
;3<==988?N?8M8?>=8CM9@7
;37
37
3$7
3
!405&
670891:;*<
*=
<
OP;3
OP;3
%%
while<biu thc boolean> do
begin
<công vic>;
end
>?
6
@ABC'1D'1D'E<công vic> <biu
thc logic> #FTrue!
6
G0,H#'1Dwhile,<biu thc logic>
FFalse.
?
6
@+A!.13
ITrue<công vic>.
IFalse0#'1Dwhile.
F-#'1D,J()'0!
6
#7+" .#
125 &
6
; + " . B C D E 8 7
%F$!GHG9I
6
6! + " . %F B
+ A !.
! *
"#$%&
6
B 13 40 13 $%
+ A !. 12
J - K !$ F L )
&
=
!405&
670891:;*<
*=
%!"9I
4G4I
"GI4/GI
G
;3<=$>?@73$<$@7
9>7 9>7
;3 Q>$
/3
<@7
9> DR7
37
;3<= :3>?89S@7
3$7
G9&
5
$1TU%7
3 7
*$189/:37
/3
;3<= :3?@7
3$<18@7
;31QV
41V319>1H
3 39>H17
;3<=T$$9?819S@7
3$7
3
7
6$1E$G 7
T 3 7
*$ 9W3$7
9I337
23
7
9>XYB3Z79>X7
;3 Q>X3Z
23
9>XXC D 7
9>D7
37
;3<[%$1 [8\ D 8[ $ % $ XX
3[@7W3$7
3
8
OPW33$
OPW33$
%%
while do
begin
<công vic>;
end
KL
6
@ABC'1D'1D'E<công vic> <biu thc
logic> #FTrue!
6
G0,H#'1Dwhile,<biu thc logic> F
False.
9
<biu thc boolean>
Repeat
Until
False
True
Repeat
]
]
6
+ " . 12 5 13/
4&
<công vic> ()BM'!
6
Nđiều kiện # <công vic> #()!
6
Nđiều kiệnO0,H#'1D!
6
-$MGHG9I
6
6! + " . %F B
+ A !.
! *
"#$%&
6
B 13 40 13 $%
+ A !. 12
J-K!$FL)
&
:
>
6$1E$G 7
T 3 7
*$ 9W3$7
9I337
23
7
9>XYB3Z79>X7
;3
23
9>XXC D 7
9>D7
37
;3<[%$1 [8\ D 8[ $ % $ XX
3[@7W3$7
3
Q>X3Z
W33$
T
'F 4N OP B 40 Q R&
S= )< ( N
7T(U/VWX&YOPN40
QR"(!Z(&
L&[ L K 40 OP \
12!8]
D& 'F 4N OP 0 )G
^ R& O* 4 ! 8
B40*:^R
)G]
<
<
$1N3G1$:7
3 7
^9>XYB_7
*$
`8293$7
9/:37
/3
7
9>X7
;3<=`>?@73$<`@7
;3<=2>?@73$<2@7
;3`Q2
`9>`D`C^7
9>D7
;3<=$ $ ?88? $ 3
?829X9F8??@73$7
3
Y
%!)G,I
4G4I
!4_U&UUVWI
"Q/^GIGI
G
79>X7
;3<=`>?@73$<`@7
;3<=2>?@73$<2@7
;3`Q2
/3
`9>`D`C^7
9>D7
37
;3<=$ $ ?88? $ 3
?829X9F8??@73$7
G9&
5=