请问为什么下面这题答案是D而不是C?What is the output of the following code fragment?(All variables are of type int.)alpha = 3; beta = 20; if (beta > 10) { int alpha = 5; beta = beta + alpha; cout

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 17:59:58
请问为什么下面这题答案是D而不是C?What is the output of the following code fragment?(All variables are of type int.)alpha = 3; beta = 20; if (beta > 10) { int alpha = 5; beta = beta + alpha; cout

请问为什么下面这题答案是D而不是C?What is the output of the following code fragment?(All variables are of type int.)alpha = 3; beta = 20; if (beta > 10) { int alpha = 5; beta = beta + alpha; cout
请问为什么下面这题答案是D而不是C?
What is the output of the following code fragment?(All variables are of type int.)
alpha = 3;
beta = 20;
if (beta > 10)
{
int alpha = 5;
beta = beta + alpha;
cout

请问为什么下面这题答案是D而不是C?What is the output of the following code fragment?(All variables are of type int.)alpha = 3; beta = 20; if (beta > 10) { int alpha = 5; beta = beta + alpha; cout
if里面的alpha是局部变量,alpha=5;下面得alpha是全局变量3;输出就是3,25了;
复习下全局,局部变量的章节