欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    C语言编程学习课件 (10).pdf

    • 资源ID:57971770       资源大小:1.28MB        全文页数:20页
    • 资源格式: PDF        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    C语言编程学习课件 (10).pdf

    Programming In CProgramming In C Programming In CProgramming In C The movie“Roaring Across the Horizon”Programming In CProgramming In C in mathematics you use x for multiplication,in C you use*.The*is used rather than to avoid any possible confusion with a variable called x.Note also that/,rather than,is used for division.Programming In CProgramming In C#include stdio.h void main()char s=7;int n=4;printf(7/4=%dn,s/n);printf(7.0/4=%fn,(float)s/n);outputoutput:7/4=1 7/4=1 not 1.75not 1.75 7.0/4=1.750000 7.0/4=1.750000 Programming In CProgramming In C The remainder operation is very interesting in C.The remainder operation is very interesting in C.The remainder is also called the modulus.Each time the hour hand reaches the 12 oclock,and it indicates that it has rotated once and the modulus becomes 0.Starting from 0,the modulus will increase by 1 in turn.Therefore,the modulus of the hour hand ranges from 0 to 11;the modulus of the minute hand ranges from 0 to 59.Programming In CProgramming In C#include stdio.h#include math.h void main()char s=A,t;/generate the random capital letter t=s+rand()%26;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C#include stdio.h#include math.h void main()char s=a,t;/generate the random lowercase letter t=s+rand()%26;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C#include stdio.h#include math.h void main()char s=0,t;/generate the numeric symbols t=s+rand()%10;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C How to simulate and generate a license plate number in How to simulate and generate a license plate number in Kunming?Kunming?The modulus operation has not only the special operators,but also the restrictions on the two operands involved in the operation.It can only operate on integers,that is,integer and data of character type can find the modulus.The floating numbers cannot find the modulus.Find the modulus for a negative number,and the sign of the result is the same as the number before the percent.Programming In CProgramming In C -7%2 :-1 15%-4:3 With the operations of division and modulus,how to take out the With the operations of division and modulus,how to take out the number of each digit of an integer?number of each digit of an integer?518/100 5 518/10%10 1 518%10 8 Type conversions and casts When doing calculations involving mixed data types,C ranks the data types in this order:promotion or widening of the data For calculations involving mixed data types,C automatically converts the value in the lower data type to a higher type.Promotion will cause no loss of data,because the higher data types occupy more memory than the lower types and can therefore hold the data precisely.Type conversions and casts Sometimes the automatic type conversion does not conform to our calculation intention.It requires the use of cast operations.(dataType)expression (float)(s/4)(float)s/4 1.000000 1.750000 Note:The operand of the cast operation is the value of the expression,not the variable itself.Operator precedence Consider the following statement:2+7 *8=72 var 2+7 *8=58 var Operator precedence 1)*,/have a higher priority than+、-2)Expressions containing operators of the same precedence are evaluated according to their associativity 3)use()()to change the order of evaluation Programming In CProgramming In C#include stdio.h void main()char d=0;int a=9,b=-5,c=23;float x;x=(a*a+c/b)%d-3.5f/(d-20);printf(x=%fn,x);x=(a*a+c/b)%d-3.5f/(d-20);(9*9+23/-5)%48-3.5/(48-20)(81+23/-5)%48-3.5/(48-20)(81-4)%48-3.5/(48-20)77%48-3.5/(48-20)29-3.5/(48-20)29-3.5/28 29-0.125 28.875 Programming In CProgramming In C The common mathematical operations,such as square root,exponent,logarithm and trigonometric function,there are standard library functions in C to complete the corresponding calculations.We only need to call library functions correctly in expressions during programming.When calling a library function,the function name must be correct,and the data type,number,and order of the arguments must be consistent with the system regulations.The function name is provided by the system.Programming In CProgramming In C Before calling a standard library function,you usually use precompiled commands to include the header file of the function in the source codes.sqrt(n)sqrt(n)pow(a,b)pow(a,b)fabs(x)fabs(x)sin(x)sin(x)rand()rand()#include “math.h”Programming In CProgramming In C Function Description Example Returned value Comments sqrt(x)Square root of x sqrt(16.000)4.000000 An integer values of x results in a complier error pow(x,y)x raised to the y power(xy)pow(2,3)pow(81,.5)8.000000 9.000000 Integer values of x and y are permitted exp(x)e raised to the x power(ex)exp(-3.2)0.040762 An integer value of x results in a complier error Programming In CProgramming In C Function Description Example Returned value Comments log(x)Natural log of x base e log(18.697)2.928363 An integer value of x results in a complier error log10(x)Common log of x base 10 log(18.697)1.271772 An integer value of x results in a complier error fabs(x)Absolute value of x fabs(-3.5)3.5000000 An integer value of x results in a complier error abs(x)Absolute value of x fabs(-2)2 An floating-point value of x return a value of 0 Programming In CProgramming In C#define PI 3.14159 ps=2*cos(2*PI/3*(a+b)*sin(PI/2*(a-b);x=(-b+sqrt(b*b-4*a*c)/(2*a);The symbols in the C expressions are written on one line,without subscripts,exponents,fractional line and other forms.The multiplication sign in algebra can be omitted,but*must be written in C expressions.Only parentheses can be used to change the precedence,not brackets or braces.Programming In CProgramming In C

    注意事项

    本文(C语言编程学习课件 (10).pdf)为本站会员(刘静)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开