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

上传人:刘静 文档编号:57975678 上传时间:2022-11-06 格式:PDF 页数:8 大小:1,020.38KB
返回 下载 相关 举报
C语言编程学习课件 (39).pdf_第1页
第1页 / 共8页
C语言编程学习课件 (39).pdf_第2页
第2页 / 共8页
点击查看更多>>
资源描述

《C语言编程学习课件 (39).pdf》由会员分享,可在线阅读,更多相关《C语言编程学习课件 (39).pdf(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Programming In CProgramming In C Programming In CProgramming In C Properties of variables The application of functions makes the C program realize the modular structure and the mutual call between functions.In addition,the characteristics such as the scope and lifetime of variables are also highligh

2、ted.int x=3;This statement embodies three basic attributes of variables:variable data type,variable name and value stored in the variable.Data type name value According to different scopes,variables in C can also be divided into two types:local variables and global variables.Programming In CProgramm

3、ing In C Global and Local Variables Local variables are variables defined within the function body or within compound statements.For example,the formal parameters of a function are local variables.int max(int a,int b)int a;a=ab?a:b;return a;void main()int a,b;printf(请输入两个整数:);scanf(%d%d,&a,&b);print

4、f(%d is maxinumn,max(a,b);Example of local variable Local variables cannot have the same name in the same scope.Error message error C2082:redefinition of formal parameter a The scope of local variablea,b in function body Formal parameter a and local variable a has the same name and scope.It is canno

5、t accept by C language.Programming In CProgramming In C#include stdio.h void main()int counter=0,i,mes;for(i=1;i=10;i+)int counter=0,k;for(k=1;kb?a:b;return(c);main()int a=8;printf(max=%d,max(a,b);code of global and local variables Analysis of program The program is executed from the main()function

6、entry.When the max()function is called,the argument a is the local variable which inside the main()function body,and the argument b is undefined in the main()function,so it is from a global variable with 5.In the max()function,the values obtained by the formal parameters correspond to the actual par

7、ameters respectively,that is,8 and 5 are compared,and the larger one is returned to the main()function and output.Programming In CProgramming In C The important points in this section:What is the scope of a variable?Where should global variables and local variables be defined?What does the compiler do when the scopes of global variables and local variables overlap?Programming In CProgramming In C

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

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

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com