C++ - Bi 1 : C u Trc C a M t Ch ng Trnh C++ C l m t trong...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Bi 1 : C u Trc C a M t Ch ng Trnh C++ C l m t trong nh ng cch t t nh t b t u h c m t ngn ng l p trnh l b ng m t ch ng trnh. V y y l ch ng trnh u tin c a chng ta : // my first program in C++ #include <iostream.h> int main () { cout << "Hello World!"; return 0; } Hello World! Ch ng trnh trn y l ch ng trnh u tin m h u h t nh ng ng i h c ngh l p trnh vi t u tin v k t qu c a n l vi t cu "Hello, World" ln mn hnh. y l m t trong nh ng ch ng trnh n gi n nh t c th vi t b ng C++ nh ng n bao g m nh ng ph n c b n m m i ch ng trnh C++ c. Hy cng xem xt t ng dng m t : // my first program in C++ y l dng ch thch. T t c cc dng b t u b ng hai d u s (//) c coi l cht thch m chng khng c b t k m t nh h ng no n ho t ng c a ch ng trnh. Chng c th c cc l p trnh vin dng gi i thch hay bnh ph m bn trong m ngu n c a ch ng trnh. Trong tr ng h p ny, dng ch thch l m t gi i thch ng n g n nh ng g m ch ng trnh chng ta lm. #include <iostream.h> Cc cu b t u b ng d u (#) c dng cho preprocessor (ai d ch h ti t ny v i). Chng khng ph i l nh ng dng m th c hi n nh ng c dng bo hi u cho trnh d ch. y cu l nh #include <iostream.h> bo cho trnh d ch bi t c n ph i "include" th vi n iostream. y l m t th vi n vo ra c b n trong C++ v n ph i c "include" v n s c dng trong ch ng trnh. y l cch c i n s d ng th vi n iostream int main () Dng ny t ng ng v i ph n b t u khai bo hm main. Hm main l i m m t t c cc ch ng trnh C++ b t u th c hi n. N khng ph thu c vo v tr c a hm ny ( u, cu i hay gi a c a m ngu n) m n i dung c a n lun c th c hi n u tin khi ch ng trnh b t u. Thm vo , do nguyn nhn ni trn, m i ch ng trnh C++ u ph i t n t i m t hm main....
View Full Document

Page1 / 65

C++ - Bi 1 : C u Trc C a M t Ch ng Trnh C++ C l m t trong...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online