版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、C Programming Language,Hong Song The School of Computer Science and Technology,Fall 2011,Introduction,Lecture One,Outline,Overview of Programs and Algorithms Overview of C Language Programming language Characteristics of C Essential Elements Simple Programming Examples How to do programming? Program
2、ming Process Programming Environment Programming style,Computer system,Hardware Software,Whats Computer System?,Overview of Programs and Algorithms,Software,program data document,What is Program?,programming language,A set of Characters and rules Can be interpreted by Computer,A set of programs,Prog
3、ram Design,Overview of Programs and Algorithms,Program -A list of computer instructions Program = Data Structure + Algorithm + Language,statements,Data, structure, algorithm,Program design- How to solve the problem algorithmic design + coding,Overview of Programs and Algorithms,e.g,How to calculate
4、the area of a swimming pool?,four steps Program design,Overview of Programs and Algorithms,Analyze,Confirm,Coding,Data structure and Algorithm,Problem Model,Debug,Programming language,Result,Steps,Keywords,- A strategy for solving a problem (a list of steps),What is Algorithm (算法),Overview of Progra
5、ms and Algorithms,Algorithm must be: Clearly and unambiguously defined. Effective, in the sense that its steps are executable. Finite, in the sense that it terminates after a bounded number of steps,Essential factors: Operator + Control,Arithmetic Operator: ,Logical Operator: and, or, not,Relational
6、 Operator: ,Transmit Operator: input, output, assign,sequence (順序),Operator,Control,decision (branch)(分支/選擇),repetition (loop)(循環(huán)),Overview of Programs and Algorithms,Overview of Programs and Algorithms,Practical Problems: There is a black ink bottle and a blue one, But Lily filled black ink into th
7、e blue bottle and blue ink into the black one by mistake. How to exchange them to the write bottle?,Step1: Get a blank red bottle. Step2: Pouring blue ink from black bottle into the red one. Step3: Pouring black ink from blue bottle into the black one. Step4: Pouring blue ink from red bottle into th
8、e blue one. Step5: End.,Analysis,A blank bottle needed,Some Presenting Forms: Human Language Flowchart Pseudo-code,Overview of Programs and Algorithms,Presenting Algorithm,Symbols in Flowchart Provided by ANSI (American National Standard Institute),Overview of Programs and Algorithms,Overview of Pro
9、grams and Algorithms,e.g Swapping two variables,Outline,Overview of Programs and Algorithms Overview of C Language Programming Language Characteristics of C Essential Elements Simple Programming Examples How to do programming? Programming Process Programming Environment Programming style,Programming
10、 Language,Natural Language Human C+ language #include main() std:cout 1 + 1; ,The development of Programming language,1960 Algol-60,1950,1960,1970,1980,1990,Fortran,Algol-60,Cobol,Simula,Pascal,Smalltalk,Ada,C,C+,Java,1963 CPL,CPL,BCPL,B,1967 BCPL,1970 B,1972 C,1985 C+,ANSI C,Overview of C Language,
11、What is C?,a general-purpose computer programming language,characters, syntax, structure, control statement, data type, operators,Operating systems, Compiler, Drivers,Characteristics of C,Overview of C Language,Small size C is modular Loose typing Structured language Low level programming readily av
12、ailable C has a very powerful set of operators C is the basis for C+ and Java C efficient on most machines,C Program Structure,Overview of C Language,program,functions,statements,expressions,Operands + operators,Characters,Character,Numeral: 0 1 2 9,Letter: ABCZ a b cz,Operator: + - = ,Others: r n t
13、 ,Statement,Expression,Control,branch: if-else; switch loop: for; while Jump: break; goto,Compound,Essential Elements,Function:,main( ), print(),Print the words: Hello, world you have to: Create the program text Compile it successfully Run it Get the output,The First Program Is Always The Same,“Hell
14、o, world.” Program,The program is stored as a text file named hello.c .c identifies the file as a C program.,program comment,library inclusions,main function,/* File: hello.c This program prints the message “Hello, world.” on the screen. */ #include void main () printf (“Hello, world.n”); ,Compile i
15、t,Run it,e.g sum = n1 + n2, How to get sum?,void main () int n1, n2, sum ; n1 = 23 ; n2 = 89 ; sum = n1 + n2 ; printf(“sum is %d n”, sum) ; ,A program to add two numbers,/*main function*/ /*variables declaration */ /* assignment */ /*assignment expression */ /*output*/,void main( ) int n1, n2, sum;
16、scanf ( “%d, %d”, ,void main () int n1, n2, sum ; n1 = 23 ; n2 = 89 ; sum = n1 + n2 ; printf(“sum is %d n”, sum) ; ,How to add any two numbers?,Identifiers,the names for variables,data types, functions, file, arrays,pointers in program. Must be different from keywords. Create an identifier by specif
17、ying it in the declaration of a variable, type, or function. Once declared, the identifier can be used in later program statements to refer to the associated value.,How to define Identifier Letters sum=0; for(i=1; i10;i+) for(j=1;j10;j+) sum+=i*j ; printf(“%dn”,sum); ,Programming style,TERMS,Compiler 編譯系統(tǒng)Instruction
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 六盤水職業(yè)技術(shù)學(xué)院《典型零件的工藝設(shè)計(jì)》2023-2024學(xué)年第一學(xué)期期末試卷
- 金肯職業(yè)技術(shù)學(xué)院《微機(jī)原理含實(shí)驗(yàn)》2023-2024學(xué)年第一學(xué)期期末試卷
- 新蘇教版一年級(jí)下冊(cè)數(shù)學(xué)第1單元第3課時(shí)《8、7加幾》作業(yè)
- 懷化學(xué)院《影視創(chuàng)作前沿技術(shù)》2023-2024學(xué)年第一學(xué)期期末試卷
- 湖北理工學(xué)院《人力資源管理咨詢與診斷》2023-2024學(xué)年第一學(xué)期期末試卷
- 資陽口腔職業(yè)學(xué)院《測(cè)試與傳感器技術(shù)》2023-2024學(xué)年第一學(xué)期期末試卷
- 小學(xué)黨員聯(lián)系群眾、服務(wù)群眾制度
- 長沙學(xué)院《材料加工過程多尺度模擬》2023-2024學(xué)年第一學(xué)期期末試卷
- 寒露節(jié)氣策劃講座模板
- 職業(yè)導(dǎo)論-房地產(chǎn)經(jīng)紀(jì)人《職業(yè)導(dǎo)論》名師預(yù)測(cè)卷3
- 礦工睡崗檢查書
- 仁恒江灣城修建幕墻工程監(jiān)理實(shí)施細(xì)則
- 廣東省佛山南海區(qū)四校聯(lián)考2023屆中考試題猜想數(shù)學(xué)試卷含解析
- 2023年江蘇蘇州工業(yè)園區(qū)管委會(huì)招聘筆試參考題庫附帶答案詳解
- GB/T 10752-2005船用鋼管對(duì)焊接頭
- 酒店婚宴銷售年度工作計(jì)劃4篇
- 健康教育工作考核記錄表
- 裝飾工程施工技術(shù)ppt課件(完整版)
- SJG 05-2020 基坑支護(hù)技術(shù)標(biāo)準(zhǔn)-高清現(xiàn)行
- 汽車維修價(jià)格表
-
評(píng)論
0/150
提交評(píng)論