Danh mục

Bài giảng Nhập môn lập trình: Bài 3 - TS. Ngô Hữu Dũng

Số trang: 40      Loại file: pdf      Dung lượng: 383.15 KB      Lượt xem: 13      Lượt tải: 0    
tailieu_vip

Phí tải xuống: 10,000 VND Tải xuống file đầy đủ (40 trang) 0
Xem trước 4 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Bài giảng Nhập môn lập trình: Bài 3 do TS. Ngô Hữu Dũng biên soạn cung cấp cho người học các kiến thức: If statement – Câu lệnh if, khối lệnh - Block, if…else statement – Câu lệnh if…else, toán tử điều kiện, lỗi thường gặp,...
Nội dung trích xuất từ tài liệu:
Bài giảng Nhập môn lập trình: Bài 3 - TS. Ngô Hữu DũngTRƯỜNG ĐẠI HỌC CÔNG NGHIỆP THÀNH PHỐ HỒ CHÍ MINHNhập môn lập trìnhLệnh rẽ nhánh/lựa chọnTS. Ngô Hữu DũngNội dungRẽ nhánh/lựa chọnLệnh if..elseLệnh switch..caseExpressionCase 1Case 2falsetrueConditionStatement(s)Case 3Statement(s)Statement(s)Statement(s)Default2Statement(s)Nhập môn lập trình - Rẽ nhánhStatement(s)If statement – Câu lệnh ifNếu Điều kiện đúng thìtrueThực hiện LệnhConditionfalsepseudocodeIF (Condition)THEN Statement(s);ENDIF;Statement(s)31.2.3.4.5.6.// if syntaxif (Condition){Statements;...}Nhập môn lập trình - Rẽ nhánhKhối lệnh - BlockKhối lệnh: Gồm nhiều câu lệnhCần đặt giữa dấu {…}Cách gọi khác: Lệnh phức, lệnh ghépConditionVí dụ:1. if2. {3.4.5.6.7. }4(Condition)StatementStatementStatementStatementtruefalse1;2;3;4;Nhập môn lập trình - Rẽ nhánhStatement 1Statement 2Statement 3Statement 4if…else statement – Câu lệnh if…else1. // if else syntaxfalsetrue2. if (Condition)Condition3. {4.Statement(s);Statement(s)Statement(s)5....6. }7. else8. { pseudocode9.Statement(s);IF (Condition)10. ...THEN Statement(s);11.}ELSE Statement(s);ENDIF;5Nhập môn lập trình - Rẽ nhánh

Tài liệu được xem nhiều: