问题
填空题
若下列程序运行时输出结果为 1,A,10.1 2,B,3.5 请将程序补充完整。 #include<iostream> using namespace std; int main() { void test(mt,char,double______); test(1,’A’,10.1); test(2,’B’); return 0; } void test(int a,char b,double c) { cout<<a<<’,’<<b<<’,’<<c<<endl; }
答案
参考答案:=3.5。
解析: 本题考查了函数默认参数的应用。本题中第一次调用test()函数数值1,A,10.11第二次调用少了个实参:却要求输出2,B,3.5,由此分析,应将test()函数的第三个参数声明为默认参数。且默认为3.5,才能达到要求输出结果。故应填入=3.5或者c=3.5。