Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
Lecture Introduction to Computer Programming - Lecture 9
Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Introduction to Computer Programming - Lecture 9
Khánh Thủy
76
1
pptx
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
The contents of this chapter include all of the following: Nested if else statement, logical operator in C, how logical operator can be used to make compound conditions, conditional operator, nested conditional operator, nested if-else, nested conditional operator, loops. | CSC141- Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 9 Thanks to Detal and Detal official website for some lecture slides http://highered.mcgrawhill.com/sites/0072978902/student_view0/ Switch Statement continued from the last Lecture Decisions Using switch The control statement that allows us to make a decision from the number of choices is called a switch, or Switch is also called a switch-case-default, since these three keywords go together to make up the control statement 5/26/2012 3 Switch --- Features The integer expression following the keyword switch could be: an integer constant like 1, 2 or 3, or a character constant like ‘a’ or an expression that evaluates to an integer like 2*4 The constant in each case must be different from all the others. The “do this” lines in the body of switch construct represent any valid C statements 5/26/2012 4 Switch --- General Format switch ( integer expression ) { case constant 1 : do this ; case constant 2 : do this ; case constant 3 : do this ; default : do this ; } 5/26/2012 5 Switch statement ---- incorrect void main( ) { int i = 2 ; switch ( i ) { case 1 : printf ( "I am in case 1 \n" ) ; case 2 : printf ( "I am in case 2 \n" ) ; case 3 : printf ( "I am in case 3 \n" ) ; default : printf ( "I am in default \n" ) ; } /* What is the out put? */ } 5/26/2012 6 Switch statement ---- incorrect output I am in case 2 I am in case 3 I am in default Why ? Correct program would be 5/26/2012 7 5/26/2012 8 void main( ) { int i = 2 ; switch ( i ) { case 1 : printf ( "I am in case 1 \n" ) ; break ; case 2 : printf ( "I am in case 2 \n" ) ; break ; case 3 : printf ( "I am in case 3 \n" ) ; break ; default : printf ( "I am in default \n" ) ; } } Switch statement ---- correct Output: I am in case 2 5/26/2012 9 void main( ) { int i = 22 ; switch ( i ) { case 121 : printf ( "I am in case 121 \n" ) ; break ; case 7 : printf ( "I am in case 7 \n" ) ; break ; case 22 : printf ( "I am in case 22 \n" ) ; . | CSC141- Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 9 Thanks to Detal and Detal official website for some lecture slides http://highered.mcgrawhill.com/sites/0072978902/student_view0/ Switch Statement continued from the last Lecture Decisions Using switch The control statement that allows us to make a decision from the number of choices is called a switch, or Switch is also called a switch-case-default, since these three keywords go together to make up the control statement 5/26/2012 3 Switch --- Features The integer expression following the keyword switch could be: an integer constant like 1, 2 or 3, or a character constant like ‘a’ or an expression that evaluates to an integer like 2*4 The constant in each case must be different from all the others. The “do this” lines in the body of switch construct represent any valid C statements 5/26/2012 4 Switch --- General Format switch ( integer expression ) { case constant 1 : do this ; case constant 2
TÀI LIỆU LIÊN QUAN
Lecture Introduction to Computer Programming - Lecture 8
Lecture Introduction to Computer Programming - Lecture 9
Lecture Introduction to Computer Programming - Lecture 26
Lecture Introduction to Computer Programming - Lecture 28
Lecture Introduction to Computer Programming - Lecture 29
Lecture Introduction to Computer Programming - Lecture 30
Lecture Introduction to Computer Programming - Lecture 31
Lecture Introduction to computer and programming - Lecture No 6
Lecture Introduction to computer and programming - Lecture No 8
Lecture Introduction to computer and programming - Lecture No 9
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.