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

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

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

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

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

    Programming In CProgramming In C The essence of calling function A C program can be composed of a main()function and several functions,and the tasks are completed by mutual calls between functions.Parameters are the main channel for data exchange between functions.Therefore,a thorough understanding of the parameters in a function and a grasp of the mechanism of parameter transfer are not only a prerequisite for the correct design and skillful application of functions,but also the key to program design and development.The essence of calling function The essence of a parameterized function call is to replace the formal parameters with actual parameters.Parameters are used to pass messages between different code blocks of a program.The actual parameters used in a function call must be exactly the same as the formal parameters in order,number,and data type.Programming In CProgramming In C#include stdio.h float f(float x,float y)float s;s=2*x*x+3*y+8;return s;void main()float a=1.2,b=3,result;result=f(a,b);printf(%6.2fn,result);(2)x=1.2 y=3 s=19.88(1)funtion be called x,y,s be created in memory Procedure of calling function formal parameter workingformal parameter working the function body be runningthe function body be running return return s (3)result=19.88 E.g.4:solvtion of f(x,y)=2x2+3y+8 Programming In CProgramming In C 1.pass by value Value passing takes constants,variables and expressions as actual parameters and passes values to the corresponding formal parameters.The actual parameter value is copied to the formal parameter which is completely isolated from the place that the information came from.So,any change of the formal parameter is not related to the actual parameter.Therefore,value passing is one-way.Array names,function names,pointers,etc.Can also be passed as actual parameters to formal parameters,in which case addresses are passed instead of values.Address passing is two-way.result E.g.2:one-way value passing#include stdio.h main()int a=2,b=3;swap(a,b);printf(“(2):a=%d,b=%dn,a,b);(1):a=3,b=2 (2):a=2,b=3 Function parameter passing 2.pass by address void swap(int a,int b)int t;t=a,a=b,b=a;printf(“(1):a=%d,b=%dn,a,b);Programming In CProgramming In C Error message error C2081:b:name in formal parameter list illegal int fun(int a,b)VC+compiler detect to arguments of function 1.Errors in formal parameter definition.Analysis of Error:When the parameter data types are the same,the data type description of the following parameters is omitted when defining the parameters.In this example,there is no data type specification for parameter.When compiling,the compiler gives an error message that parameter b is illegal.Programming In CProgramming In C VC+compiler detect to arguments of function Error message error C2198:fun:too few actual parameters#include stdio.h int fun(int a,int b)return a+b;main()printf(%dn,fun(4);2.The number of actual parameters is inconsistent with that of formal parameters.Analysis of Error:The number of actual argument must be the same as the formal parameter.Programming In CProgramming In C#include stdio.h int fun(int a,int b)return a+b;main()printf(%dn,fun(4.5,3);Warning information warning C4244:function:conversion from const double to int,possible loss of data VC+compiler detect to arguments of function 3.The data type of the actual parameter is different from that of the formal parameter.Analysis of Error:When the data type of the actual parameter is different from that of the formal parameter,the compiler will force the data type of the actual parameter to the data type of the formal parameter if the user ignores the warning,which may result in data loss.If the warning is ignored,the run result is 7 Programming In CProgramming In C VC+compiler detect to arguments of function result 7#include stdio.h int fun(int a,int b,int c)return a+b;main()printf(“%dn”,fun(4,3,5);4.The formal parameters are redundant.Analysis of Error:If this happens to a local variable in a function body,the compiler will give a warning that the variable is not referenced.for example:x:unreferenced local variable However,the compiler will not give a warning for the redundancy of formal parameters.Programming In CProgramming In C

    注意事项

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

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




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

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

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

    收起
    展开