有以下程序:  #include<stdio.h>  int fun(int x,int y)  { if(x!=y)   return((x+y)/2);   else return(x);  }  main()  { int a=4,b=5

admin2022-10-24  41

问题 有以下程序:
 #include<stdio.h>
 int fun(int x,int y)
 {  if(x!=y)
    return((x+y)/2);
    else return(x);
 }
 main()
 {  int a=4,b=5,c=6;
    printf("%d\n",fun(2*a,fun(b,c)));
 }
 程序的运行结果是(          )。

选项 A、6
B、3
C、8
D、12

答案A

解析 本题中,fun函数第1次调用为fun(8,fun(5,6))。因为fun(5,6)的返回值为5,所以第2次调用为fun(8,5),即返回值为6。故本题答案为A选项。
转载请注明原文地址:https://kaotiyun.com/show/lWkp777K
0

相关试题推荐
最新回复(0)