柠檬试题库
search
首页
计算机
公务员
驾照
关于
share
以下关于return语句的叙述中正确的是
A.一个自定义函数中必须有一条return语句
B.一个自定义函数中可以根据不同情况设置多条return语句
C.定义成void类型的函数中可以有带返回值的return语句
D.没有return语句的自定义函数在执行结束时不能返回到调用处
热度🔥1,103
参考答案:B
解析:
【解析】在函数中允许有多个return语句,但每次调用只能有一个return 语句被执行,因此只能返回一个函数值,A选项描述错误。定义成void类型的函数,不允许从该函数取得返回值,也不允许使用return语句,C选项描述错误。没有return语句的函数在执行到函数的最后一条语句后会自动返回到调用处,D选项描述错误。因此B选项正确。
复制题目向AI提问
content_copy
content_copy
扫码免费计算机二级刷题
2025年计算机等级考试题库
推荐
有以下程序: # include typedef struct { int b, p; } A; void f(A c) /* 注意:c是结构变量名 */ { int j; c.b += 1; c.p+=2; } main() { int i; A a={1,2}; f(a); printf("%d,%d\n", a.b, a.p); } 程序运行后的输出结果是( )。
有以下程序 #include typedef struct stu { char name[10]; char gender; int score; } STU; void f(STU *a, STU *b) { *b = *a; printf("%s,%c,%d,", b->name, b->gender, b->score); } main() { STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350}; f(&a,&b); printf("%s,%c,%d\n", b.name, b.gender, b.score); } 程序的运行结果是
μCOS-II操作系统的下面4个主要函数中,只有一个是与任务调度相关的,它是( )。
标签
二级C语言
语句
函数
return
返回