投稿  收藏 

题目信息

题目类型
练习
题目年份
2024
题目题型
单选题
关 键 词
变量

题目题干

指出下列各文件中变量的存储类型、作用域与生存期,写出下列程序的运行结果。在第二个文件中能否将第一个文件中的变量 z 定义为外部变量?
//文件名:exercise5_18.cpp
#include <iostream> //1
using namespace std; //2
int x=1,y=2; //3
static int z=3; //4
extern void add(void); //5
int main( ) //6
{ add(); //7
cout<<"x="<<x<<'\t'<<"y="<<y <<'\t'<<"z="<<z<<endl; //8
return 0; //9
} //10
//文件名:exercise5_181.cpp
#include <iostream> /11
using namespace std; //12
extern int x,y; //13
void add(void) //14
{ x+=3; //15
y+=4; //16
cout<<"x="<<x<<'\t'<<"y="<<y<<endl; //17

指出下列各文件中变量的存储类型、作用域与生存期,写出下列程序的运行结果。在第二个文件中能否将第一个文件中的变量 z 定义为外部变量? //文件名:exercise5_18.cpp #include <iostream> //1 using namespace std; //2 int x=1,y=2; //3 static int z=3; //4 extern void add(void); //5 int main( ) //6 { add(); //7 cout<<

答案解析

相关题目

编写一个函数,把华氏温度转换成摄氏温度,温度转换公式为:c=(f -32) * 5/9。在主函数中输入华氏温度值,转换后输出相应的摄氏温度值。
指出下列各文件中变量的存储类型、作用域与生存期,写出下列程序的运行结果。在第二个文件中能否将第一个文件中的变量 z 定义为外部变量? //文件名:exercise5_18.cpp #include &
指出下列各函数中各变量的存储类型、作用域与生存期,写出下列程序的运行结果。 #include <iostream> //0 using namespace std; //1 int mai
指出下列程序各函数中的全局变量与局部变量、静态变量与动态变量,以及各变量的存储类型、作用域与生存期,并写出下列程序的运行结果。 #include <iostream> //0  using
写出下列程序的运行结果。 #include <iostream> using namespace std; int a=10; int main( ) {int a=20,b=30; {i
写出下列以数组为参数的函数调用运行结果。 #include <iostream>  #include <string>  using namespace std;  int m
写出下列递归程序的递归公式、限制条件、结束条件及运行结果。
写出下列程序运行后的输出图形。
写出下列程序的运行结果。 #include <iostream>  using namespace std;  void modify(int x,int y)  { cout<&l
设 A 为 m 行 n 列矩阵,B 为 n 行 k 列矩阵,C 为 m 行 k 列矩阵。设计矩阵乘法程序,能完成 C=A * B 的操作。m、n 与 k 用 define 定义为常量,其值由用户自定义

提示声明

  • 免责声明:本站资源均来自网络或者用户投稿,仅供用于学习和交流:如有侵权联系删除!
  • 温馨提示:本文属于积分文章,需要充值获得积分或升级VIP会员,也可在会员中心投稿获取。

猜你喜欢