




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、南京審計(jì)學(xué)院南京審計(jì)學(xué)院信息科學(xué)與技術(shù)學(xué)院信息科學(xué)與技術(shù)學(xué)院孫玉星孫玉星 2/983/98preprocessor instructionpengisytiharan globlmain ()pengisytiharan setempatstatementglobal declarationlocal declaration4/98#include /*函數(shù)功能函數(shù)功能:計(jì)算兩個(gè)整數(shù)相加之和計(jì)算兩個(gè)整數(shù)相加之和 入口參數(shù)入口參數(shù):整型數(shù)據(jù)整型數(shù)據(jù)a和和b 返回值:返回值: 整型數(shù)整型數(shù)a和和b之和之和*/int add(int a, int b)return (a + b);/*主函數(shù)主函數(shù)*
2、/main()int x, y, sum = 0;printf(input two integers:);scanf(%d%d, &x, &y); /*輸入兩個(gè)整型數(shù)輸入兩個(gè)整型數(shù)x和和y*/sum = add(x, y); /*調(diào)用函數(shù)調(diào)用函數(shù)add計(jì)算計(jì)算x和和y相加之和相加之和*/printf(sum = %dn, sum); /*輸出輸出x和和y相加之和相加之和*/5/986/987/988/989/9810/9811/98example:12/9813/98example:number1?number2?25232314/98algorithm syntax rules:expres
3、sions type must be the same as variables typevalid example:invalid example:15/98example:calculate and display the price of a number of apples if the quantity in kg and price per kg are given.input: and output:process: = * 16/98example:17/98example:quantity? priceperkg? price?4.509.00218/98example:19
4、/9820/98數(shù)據(jù)類型數(shù)據(jù)類型基本類型基本類型構(gòu)造類型構(gòu)造類型指針類型指針類型空類型空類型整型整型實(shí)型(浮點(diǎn)型)實(shí)型(浮點(diǎn)型)字符型字符型枚舉類型枚舉類型數(shù)組類型數(shù)組類型結(jié)構(gòu)體類型結(jié)構(gòu)體類型共用體類型共用體類型單精度實(shí)型雙精度實(shí)型基本整型長(zhǎng)整型短整型無(wú)符號(hào)整型21/9822/9823/9824/9825/9826/9827/9828/9829/9830/9831/98#include main()printf(data type number of bytesn);printf(- -n);printf(char %dn, sizeof(char);printf(int %dn, sizeo
5、f(int);printf(short int %dn, sizeof(short);printf(long int %dn, sizeof(long);printf(float %dn, sizeof(float);printf(double %dn, sizeof(double);32/98階碼符號(hào)階碼符號(hào)階碼的數(shù)值階碼的數(shù)值尾數(shù)符號(hào)尾數(shù)符號(hào)尾數(shù)的數(shù)值尾數(shù)的數(shù)值階碼階碼j尾數(shù)尾數(shù)s33/9834/9835/9836/98b, 98b, 66b, 98b, 6637/9838/9839/98area = 88.247263circumference = 33.30085440/9841/98
6、42/9843/98example:44/9845/9846/9847/98example:浮點(diǎn)數(shù)除法浮點(diǎn)數(shù)除法floating division or or both are floats整數(shù)除法整數(shù)除法integer division and are integers48/98example:49/98example:50/98example:51/9852/9853/98example:1252102remainderresult54/9855/98example:-73-2-6-1remainderresult56/98example:7-3-261remainderresult57/
7、98example:58/9859/98examples:60/9861/98example: 62/98example:63/9864/9865/98#include main( ) float price, discount, total; printf(“buying price : “); scanf(“%f”, &price); printf(“ndiscount rate : “); scanf(“%f”, &discount); total = price * discount; printf(“the total price is %.2fn”, total);buying p
8、rice: _discount?price? total?buying price: 10.00_10.00buying price: 10.00discount rate: _buying price: 10.00discount rate: 0.25_0.252.50buying price: 10.00discount rate: 0.25_buying price: 10.00discount rate: 0.25the total price is 2.50_example:66/9867/98example:int number, total;float start_x, star
9、t_y;. . . number = total = 0;start_x = start_y = 100.0;total?number?start_x?start_y?00100.0100.068/9869/98example:num = num + 5;num152070/98example:num += 5;71/9872/98operationexamples of expressiondescription+=num += 5;num = num + 5;-=num -= 5;num = num 5;*=num *= 5;num = num * 5;/=num /= 5;num = n
10、um / 5;%=num %= 5;num = num % 5;73/98doublefloatlongunsignedintchar,short低高74/9875/98example: int x = 10;float y;y = (float)x;x10y?10.00000076/98example: int total, number;float average;average = total / number;total15number2average?7.000000兩個(gè)整數(shù)運(yùn)算的結(jié)果兩個(gè)整數(shù)運(yùn)算的結(jié)果還是整數(shù),不是浮點(diǎn)數(shù)還是整數(shù),不是浮點(diǎn)數(shù)77/98example: int tot
11、al, number;float average;average = (float)total / number;total15number2average?7.50000078/98operationdescriptionexamples of expressionvalueless than6 91 (true)=less than or equal to5 greater than2 60 (false)=greater than or equal to9 = 51 (true)=equal to7 = 50 (false)!=not equal to6 != 51 (true)79/98a b = cd = a bch a + 1 d = a + b c3 = x b)= cd = (a b)ch (a + 1)d = (a + b) c)(3 = x) a )a2b5c15d1783/98example: (a = 1) & (b = 5) a2b5c15d1784/98example: (c = ( b * 3 ) ) | (a = 3) a2b5c15d1785/98example: ! ( ( a d ) ) a2b5c15d1786/9887/9888/9889/98example:j = +i - 2i5
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年分析實(shí)驗(yàn)室專用純水機(jī)項(xiàng)目可行性研究報(bào)告
- 廣東省高中化學(xué)1.2有機(jī)化合物的結(jié)構(gòu)與性質(zhì)第二課時(shí)有機(jī)物的同分異構(gòu)現(xiàn)象導(dǎo)學(xué)案魯科版選修5
- 安徽專版2024中考?xì)v史復(fù)習(xí)方案第一部分中國(guó)古代史第07課時(shí)明清時(shí)期統(tǒng)一多民族國(guó)家的鞏固與發(fā)展提分訓(xùn)練
- 新課標(biāo)2024年中考生物復(fù)習(xí)第一單元生物與環(huán)境課時(shí)訓(xùn)練01認(rèn)識(shí)生物及其環(huán)境
- DB54T 0431-2025 藏雞林下養(yǎng)殖技術(shù)規(guī)范
- 2024榆林市城市投資經(jīng)營(yíng)集團(tuán)有限公司招聘(6人)筆試參考題庫(kù)附帶答案詳解
- 2024廣東廣州市花都宏信實(shí)業(yè)有限公司招聘考察人員筆試參考題庫(kù)附帶答案詳解
- 2024廣東東莞市濟(jì)川城市開(kāi)發(fā)投資有限公司招聘4人筆試參考題庫(kù)附帶答案詳解
- 2024年濱州國(guó)有資本投資運(yùn)營(yíng)集團(tuán)有限公司公開(kāi)招聘工作人員(含補(bǔ)錄)筆試筆試參考題庫(kù)附帶答案詳解
- 吊頂輔料明細(xì)合同范例
- 2024年海東市第二人民醫(yī)院自主招聘專業(yè)技術(shù)人員筆試真題
- 2024年廣西壯族自治區(qū)中考化學(xué)試題含答案
- 老年人能力、綜合征評(píng)估量表、綜合評(píng)估基本信息表、護(hù)理服務(wù)項(xiàng)目清單
- 人工智能崗位招聘筆試題及解答(某大型央企)2025年
- 煉油廠化工廠車間崗位勝任力素質(zhì)模型設(shè)計(jì)
- 電子課件-《市場(chǎng)營(yíng)銷》-A45-2298完整版教學(xué)課件全書(shū)電子講義(最新)
- 紅土鎳礦濕法冶煉技術(shù)綜述
- 隧道開(kāi)挖作業(yè)臺(tái)車計(jì)算書(shū)
- 水利水電工程金屬結(jié)構(gòu)與機(jī)電設(shè)備安裝安全技術(shù)規(guī)程
- 新視野大學(xué)英語(yǔ)讀寫(xiě)譯4U校園第一單元課后測(cè)試答案
- 國(guó)學(xué)基本知識(shí)(課堂PPT)
評(píng)論
0/150
提交評(píng)論