




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
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í)型基本整型長整型短整型無符號(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. 本站所有資源如無特殊說明,都需要本地電腦安裝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è)按摩師必學(xué)內(nèi)容
- 非專業(yè)人士如何輕松操作實(shí)驗(yàn)儀器指南
- 財(cái)務(wù)管理軟件優(yōu)化提升企業(yè)運(yùn)營效率的關(guān)鍵
- 2025年大唐華銀電力股份有限公司高校畢業(yè)生招聘筆試參考題庫附帶答案詳解
- 金融科技對(duì)傳統(tǒng)金融業(yè)的影響及前景分析報(bào)告
- 淮安專版2024中考?xì)v史復(fù)習(xí)方案第06課時(shí)遼宋夏金元時(shí)期:民族關(guān)系發(fā)展和社會(huì)變化課時(shí)提分練習(xí)
- 超鏈接在客戶服務(wù)中的應(yīng)用與優(yōu)化
- 課標(biāo)專用天津市2024高考英語二輪復(fù)習(xí)滾動(dòng)題組7單項(xiàng)填空書面表達(dá)
- 西藏2025年01月2025年西藏公務(wù)員考試(385人)國家公務(wù)員考試消息筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 跨學(xué)科教育培養(yǎng)全面發(fā)展的現(xiàn)代人才
- 電子課件-《市場(chǎng)營銷》-A45-2298完整版教學(xué)課件全書電子講義(最新)
- Q∕SY 06349-2019 油氣輸送管道線路工程施工技術(shù)規(guī)范
- CEO自戀及其經(jīng)濟(jì)后果研究:以格力電器為例
- 紅土鎳礦濕法冶煉技術(shù)綜述
- 六鑫伺服刀塔說明書LS系列
- 19.骨折術(shù)后內(nèi)固定取出臨床路徑
- 水利水電工程金屬結(jié)構(gòu)與機(jī)電設(shè)備安裝安全技術(shù)規(guī)程
- 腎內(nèi)科臨床診療規(guī)范(南方醫(yī)院)
- 珍愛生命 安全第一 中小學(xué)主題教育班會(huì)
- 二十八星宿(課堂PPT)
- OQC出貨檢驗(yàn)報(bào)告
評(píng)論
0/150
提交評(píng)論