Bài giảng Lập trình C# 2010: Chương 3 - ĐH Công nghệ Đồng Nai
Thông tin tài liệu:
Nội dung trích xuất từ tài liệu:
Bài giảng Lập trình C# 2010: Chương 3 - ĐH Công nghệ Đồng NaiDONG NAI UNIVERSITY OF TECHNOLOGY 2 Format Code DONG NAI UNIVERSITY OF TECHNOLOGYFormat DescriptionCodeC or c Formats the string as currency. Precedes the number with an appropriate currency symbol ($ in the US).D or d Formats the string as a decimal. Displays number as an integer.N or n Formats the string with commas and two decimal places. 3 Format Code DONG NAI UNIVERSITY OF TECHNOLOGYFormat DescriptionCodeE or e Formats the number using scientific notation with a default of six decimal placesF or f Formats the string with a fixed number of decimal places (two by default).G or g General. Either E or F.X or x Formats the string as hexadecimal.DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY Logical andConditional Operators DONG NAI UNIVERSITY OF TECHNOLOGY 1 2 Logical Conditional AND(&) AND (&&) 3 4 Logica Conditional l OR (|) OR (||)5 6 Logical exclusive Logical NOT OR or XOR (!) (^) DONG NAI UNIVERSITY OF TECHNOLOGY Used to add multipleconditions to a statement DONG NAI UNIVERSITY OF TECHNOLOGYexp1 exp2 exp1&&exp2false false falsefalse true falsetrue false falsetrue true true Truthtableforthe&& (logicalAND)operator. DONG NAI UNIVERSITY OF TECHNOLOGYExp1 exp2 exp1||exp2false false falsefalse true truetrue false truetrue true True Truthtableforthe|| (logicalOR)operator. DONG NAI UNIVERSITY OF TECHNOLOGYexp1 exp2 exp1 ^ exp2false false falsefalse true truetrue false truetrue true false Truthtableforthelogical exclusiveOR(^)operator. DONG NAI UNIVERSITY OF TECHNOLOGYexpression !expressionfalse trueTrue false Truthtableforoperator! (logicalNOT). DONG NAI UNIVERSITY OF TECHNOLOGY Control Structures• Program of control – Program performs one statement then goes to next line • Sequential execution DONG NAI UNIVERSITY OF TECHNOLOGY– Different statement other than the next one executes • Selection structure – The if and if/else statements • Repetition structure – The while and do/while loops – The for and foreach loops DONG NAI UNIVERSITY OF TECHNOLOGY total = total + grade;add grade to total counter = counter + 1;add 1 to counterFlowcharting C#’s sequencestructure. DONG NAI UNIVERSITY OF TECHNOLOGY if Selection StructureØ Causes the program to make a selectionØ Chooses based on conditional • Any expression that evaluates to a bool type • True: perform an action • False: skip the actionØ Single entry/exit pointØ Require no semicolon in syntax DONG NAI UNIVERSITY OF TECHNOLOGY if Selection Structure trueconditions do somethingfalse If/else Selection DONG NAI UNIVERSITY OF TECHNOLOGYØ Structure Alternate courses can be taken when the statement is falseØ Rather than one action there are two choicesØ Nested structures can test many casesØ Structures with many lines of code need braces ({) • Can cause errors ü Fatal logic error ü Nonfatal logic error DONG NAI UNIVERSITY OF TECHNOLOGY If/else Selection Structure false true Conditionsdo something else do something DONG NAI UNIVERSITY OF TECHNOLOGY Conditional Operator (?:)C#’s only ternary operatorSimilar to an if/elsestructureThe syntax is: boolean value ? if true : if false MessageBox.Show(dtb>=5? “Dau”: “Rot”); Loops DONG NAI UNIVERSITY OF TECHNOLOGYØ Repeating a series of instructionsØ Each repetition is called an iterationØ Types of Loops o Do ü Use when the number of iterations is unknown o ...
Tìm kiếm theo từ khóa liên quan:
Kỹ thuật lập trình Công nghệ lập trình Ngôn ngữ lập trình C Học lập trình C Visual Studio 2010 Kỹ thuật lập trìnhGợi ý tài liệu liên quan:
-
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 266 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 208 0 0 -
101 trang 200 1 0
-
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 195 0 0 -
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 168 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 153 0 0 -
Tìm hiểu về ngôn ngữ lập trình C: Phần 1 - Quách Tuấn Ngọc
211 trang 149 0 0 -
161 trang 130 1 0
-
Báo cáo thực tập Công nghệ thông tin: Lập trình game trên Unity
27 trang 118 0 0 -
Giáo trình Vi điều khiển PIC: Phần 1
119 trang 116 0 0 -
Giáo trình về phân tích thiết kế hệ thống thông tin
113 trang 114 0 0 -
Bài giảng Phương pháp lập trình: Chương 9 - GV. Từ Thị Xuân Hiền
36 trang 112 0 0 -
LUẬN VĂN: Tìm hiểu kỹ thuật tạo bóng cứng trong đồ họa 3D
41 trang 109 0 0 -
Bài giảng Kỹ thuật lập trình - Chương 10: Tổng kết môn học (Trường Đại học Bách khoa Hà Nội)
67 trang 106 0 0 -
Đồ án vi xử lý đề tài : nghiên cứu thiết kế mạch đo khoảng cách sử dụng vi điều khiển Pic 16F887
45 trang 97 1 0 -
Giáo trình Nhập môn lập trình VB6: Phần 2
184 trang 93 0 0 -
Tìm hiểu về ngôn ngữ lập trình C: Phần 2 - Quách Tuấn Ngọc
210 trang 89 0 0 -
Giáo trình toán rời rạc - Phụ lục 2
15 trang 85 0 0 -
Giáo trình Nhập môn lập trình VB6: Phần 1
246 trang 85 0 0 -
Nghiên cứu triển khai nội địa hóa máy tính thương hiệu Việt Nam
585 trang 83 0 0