C语言第6章_函数题库.pptVIP

  • 13
  • 0
  • 约1.4万字
  • 约 81页
  • 2017-07-21 发布于湖北
  • 举报
全局变量和局部变量 #includestdio.h int a,b; void fun() { a=100;b=200; } void main() {int a=5,b=7; fun(); printf(%d%d\n,a,b); } 分 析 程 序 运 行 结 果 全局变量 局部变量 * 全局变量和局部变量 局部变量  在函数(复合语句)内部定义的变量。 全局变量  在函数外部定义的变量。 两种变量的区别  作用域不同 (作用域: 变量可以被使用的范围) 全局变量:定义点至源程序文件结束。  局部变量:定义点至本函数(复合语句)结束 * 全局变量和局部变量 #include stdio.h void main() {int a,b; scanf(%d%d,a,b); if(ab) { int t; t=a; a=b; b=t; } printf(%d,%d\n,a,b); } #includestdio.h int a,b; void fun() { a=100;b=200; } void main() { int a=5,b=7; fun(); printf(%d%d\n,a,b); } * 全局变量和局部变量 #includeio

文档评论(0)

1亿VIP精品文档

相关文档