GiaoTrinhC_Aptech - Gio trnh Lp trnh C cn bn Trang 1 MC LC...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Giáo trình L ập tr ình C c ăn bản Trang 1 Tai lieu tham khao M ỤC LỤC BÀI 1 : NGÔN NG Ữ LẬP TR ÌNH & PHƯƠNG PHÁP LẬP TR ÌNH ...................... 7 1.1 M ục ti êu ................................................................................................................................ 7 1.2 Lý thuy ết ............................................................................................................................... 7 1.2.1 Ngôn ng ữ lập tr ình (Programming Language) ............................................................. 7 1.2.1.1 Thu ật giải (Algorithm) ............................................................................................. 7 1.2.1.2 Chương tr ình (Program) ......................................................................................... 7 1.2.1.3 Ngôn ng ữ lập tr ình (Programming language) ....................................................... 8 1.2.2 Các bước lậ p trình ........................................................................................................... 8 1.2.3 K ỹ thuật lập tr ình ............................................................................................................ 8 1.2.3.1 I-P-O Cycle (Input-Pprocess-Output Cycle) (Quy trình nh ập -x ử lý -xu ất) ........ 8 1.2.3.2 S ử dụng lưu đồ (Flowchart) ..................................................................................... 9 BÀI 2 : LÀM QUEN L ẬP TR ÌNH C QUA CÁC VÍ D Ụ ĐƠN G I ẢN ...................... 12 2.1 M ục ti êu .............................................................................................................................. 12 2.2 N ội dung .............................................................................................................................. 12 2.2.1 Kh ởi động v à thoát BorlandC ....................................................................................... 12 2.2.1.1 Kh ởi động ................................................................................................................ 12 2.2.1.2 Thoát ........................................................................................................................ 13 2.2.2 Các ví d ụ đơn giản ......................................................................................................... 13 2.2.2.1 Ví d ụ 1 ...................................................................................................................... 13 2.2.2.2 Ví d ụ 2 ...................................................................................................................... 15 2.2.2.3 Ví d ụ 3 ...................................................................................................................... 16 2.2.2.4 Ví d ụ 4 ...................................................................................................................... 16 BÀI 3 : CÁC THÀNH PH ẦN TRONG NGÔN NG Ữ C ......................................... 18 3.1 M ục ti êu .............................................................................................................................. 18 3.2 N ội dung .............................................................................................................................. 18 3.2.1 T ừ khóa ........................................................................................................................... 18 3.2.2 Tên ................................................................................................................................... 18 3.2.3 Ki ểu dữ liệu .................................................................................................................... 18 3.2.4 Ghi chú ............................................................................................................................ 19 3.2.5 Khai báo bi ến ................................................................................................................. 19 3.2.5.1 Tên bi ến ................................................................................................................... 19 3.2.5.2 Khai báo bi ến .......................................................................................................... 19 3.2.5.3 V ừa khai báo vừa khởi gán .................................................................................... 20 3.2.5.4 Ph ạm vi của biế n ..................................................................................................... 20 BÀI 4 : NH ẬP / XUẤT DỮ LIỆU .......................................................................... 21 4.1 M ục ti êu .............................................................................................................................. 21 4.2 N ội dung .............................................................................................................................. 21
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Giáo trình L ập tr ình C c ăn bản Trang 2 Tai lieu tham khao 4.2.1 Hàm printf ...................................................................................................................... 21 4.2.2 Hàm scanf ....................................................................................................................... 24 4.3 Bài t ập ................................................................................................................................. 25 BÀI 5 : C ẤU TRÚC RẼ NHÁNH CÓ ĐIỀU KIỆN ................................................ 26 5.1 M ục ti êu .............................................................................................................................. 26 5.2 N ội dung .............................................................................................................................. 26 5.2.1 L ệnh v à kh ối lệnh ........................................................................................................... 26 5.2.1.1 L ệnh ......................................................................................................................... 26 5.2.1.2 Kh ối lệnh ................................................................................................................. 26 5.2.2 L ệnh if ............................................................................................................................. 26 5.2.2.1 D ạng 1 (if thiếu) ...................................................................................................... 26 5.2.2.2 D ạng 2 (if đ ủ) ......................................................................................................... 30 5.2.2.3 C ấu trúc else if ........................................................................................................ 33 5.2.2.4 C ấu trúc if lồng ....................................................................................................... 37 5.2.3 L ệnh switch ..................................................................................................................... 41 5.2.3.1 C ấu trúc switch…case (switch thiếu) .................................................................... 41 5.2.3.2 C ấu trúc switch…case…default (switch đủ) ........................................................ 44 5.2.3.3 C ấu trúc switch lồng ............................................................................................... 46 5.3 Bài t ập ................................................................................................................................. 48 5.3.1 S ử dụng lệnh if ............................................................................................................... 48 5.3.2 S ử dụng lệnh switch ....................................................................................................... 49 5.4 Bài t ập l àm thêm ................................................................................................................ 49 BÀI 6 : C ẤU TRÚC V ÒNG L ẶP .......................................................................... 51 6.1 M ục ti êu .............................................................................................................................. 51 6.2 N ội dung .............................................................................................................................. 51 6.2.1 L ệnh for ........................................................................................................................... 51 6.2.2 L ệnh break ...................................................................................................................... 56 6.2.3 L ệnh continue ................................................................................................................. 56 6.2.4 L ệnh while ...................................................................................................................... 56 6.2.5 L ệnh do…while .............................................................................................................. 58 6.2.6 Vòng l ặp lồng nhau ........................................................................................................ 60 6.2.7 So sánh s ự khác nhau của các v òng l ặp ....................................................................... 61 6.3 Bài t ập ................................................................................................................................. 62 BÀI 7 : HÀM ......................................................................................................... 65 7.1 M ục ti êu .............................................................................................................................. 65 7.2 N ội dung .............................................................................................................................. 65 7.2.1 Các ví d ụ về h àm ............................................................................................................ 65 7.2.2 Tham s ố dạng tham biến v à tham tr ........................................................................... 68
Image of page 2
Giáo trình L ập tr ình C c ăn bản Trang 3 Tai lieu tham khao 7.2.3 S ử dụng biến to àn c ục ................................................................................................... 69 7.2.4 Dùng d ẫn hướng #define ............................................................................................... 71 7.3 Bài t ập ................................................................................................................................. 71 BÀI 8 : M ẢNG V À CHU ỖI ................................................................................... 72 8.1 M ục ti êu .............................................................................................................................. 72 8.2 N ội dung .............................................................................................................................. 72 8.2.1 M ảng ................................................................................................................................ 72 8.2.1.1 Cách khai báo m ảng ............................................................................................... 72 8.2.1.2 Tham chi ếu đến từng phần tử mảng .................................................................... 72 8.2.1.3 Nh ập dữ liệu cho mảng .......................................................................................... 73 8.2.1.4 Đọc dữ liệu từ mảng ............................................................................................... 73 8.2.1.5 S ử dụng biến kiểu khá c .......................................................................................... 74 8.2.1.6 K ỹ thuật Sentinal .................................................................................................... 74 8.2.1.7 Kh ởi tạo mảng ......................................................................................................... 75 8.2.1.8 Kh i t ạo mảng không bao hàm kích thước .......................................................... 76 8.2.1.9 M ảng nhiều chiều ................................................................................................... 76 8.2.1.10 Tham chi ếu đến từng phần tử mảng 2 chiều ....................................................... 76 8.2.1.11 Nh ập dữ liệu cho mảng 2 chiều ............................................................................. 77 8.2.1.12
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern