




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 江蘇南京秦淮中學(xué)2024~2025學(xué)年高二下冊(cè)期末調(diào)研數(shù)學(xué)試題學(xué)生卷
- 江蘇常州高級(jí)中學(xué)2024~2025學(xué)年高一下冊(cè)期末質(zhì)量檢查數(shù)學(xué)試題學(xué)生卷
- 2024~2025學(xué)年山東泰安新泰七年級(jí)下冊(cè)4月期中數(shù)學(xué)試題【帶答案】
- 過(guò)敏原特異性免疫治療研究考核試卷
- 災(zāi)害影響下的公共設(shè)施應(yīng)急恢復(fù)計(jì)劃考核試卷
- 醫(yī)藥研發(fā)外包服務(wù)市場(chǎng)分析考核試卷
- 部編道德與法治三年級(jí)下冊(cè)教案
- 2025年中國(guó)PET薄膜帶數(shù)據(jù)監(jiān)測(cè)報(bào)告
- 2025年中國(guó)DVD沖壓件數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025年中國(guó)6-16防區(qū)擴(kuò)展防盜報(bào)警系統(tǒng)數(shù)據(jù)監(jiān)測(cè)報(bào)告
- PTBD管路維護(hù)技術(shù)
- 220kV變電運(yùn)行中的故障排除方法
- 煤礦典型事故案例分析培訓(xùn)課件
- 15D501 建筑物防雷設(shè)施安裝
- 試產(chǎn)總結(jié)報(bào)告模板
- 滁州景航農(nóng)業(yè)科技有限公司蚯蚓養(yǎng)殖、玉米、菌菇種植協(xié)同處理處置秸稈、畜禽糞便和生活污泥項(xiàng)目環(huán)境影響報(bào)告表
- DB37-T 4466-2021 海洋環(huán)境人防工程耐久性設(shè)計(jì)規(guī)范
- 壓力鋼管加工及安裝施工方案(水利)
- 正庚烷-正辛烷連續(xù)精餾塔設(shè)計(jì)
- 人教版高中數(shù)學(xué)選修2-3全部教案
- 防溺水安全教育課件PPT(完美版)
評(píng)論
0/150
提交評(píng)論