首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include #include typedef struct{char name[9];char sex;float score[2];}ST; void fun(ST x) { STU y={’’Tom’’,’m’,98.0,90.0}
有以下程序: #include #include typedef struct{char name[9];char sex;float score[2];}ST; void fun(ST x) { STU y={’’Tom’’,’m’,98.0,90.0}
admin
2021-07-09
38
问题
有以下程序:
#include
#include
typedef struct{char name[9];char sex;float score[2];}ST;
void fun(ST x)
{
STU y={’’Tom’’,’m’,98.0,90.0};
int i;
strcpy(x.name,y.name);
x.sex=y.sex:
for(i=0;i<2;i++)
x.score
=y.score [1];
}
main()
{
ST student={’’Bob’’,’f,99.2,89.0};
fun(student);
printf(’’%s,%c,%2.0f,%2.0f\n’’,student.name,student.sex,student.score[0],student.
score[1]);
}
程序运行后的输出结果是( )。
选项
A、Tom,m,98,90
B、Bob,f,99,89
C、Bob,f,98,90
D、Tom,f,99,89
答案
B
解析
子函数的功能是将形参的值用一个固定的值覆盖,但因为是值传递,所以实参的值不会变化,所以在主函数中的结构体astudent的值没有发生变化。
转载请注明原文地址:https://kaotiyun.com/show/0Ztp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
程序设计的任务包括()。
有以下程序#include<stdio.h>#include<string.h>main(){inti,len;charb[]="WelcomeyoutoBeijing!";len=strlen
有以下程序:#include<stdio.h>stmctS{intn;inta[20];};voidf(stmctS*p){inti,j,t;for(i=0;i<p->n-1;i++)for(j=i+1;j<p->n;j++)if
若变量均已正确定义并赋值,以下合法的C语言赋值语句是()。
有以下程序#include<stdio.h>voidmain(){chars[]={"01axy"};inti,n=0;for(i=0;s[i]!=0;i++)if(s[i]<
以下语句的输出结果是printf("%d\n",strlen("\t\"\065\xff\n"));()。
若有定义:chars[30]={0};运行时输入:Thisisastring.<回车>则以下不能正确读入整个字符串Thisisastring.到字符数组s中的语句组是()。
设有定义:intk=0;以下选项的4个表达式中与其他3个表达式的值不相同的是()。
随机试题
药品贮存时有问题待处理的药品应挂
Theestablishmentofthecompanyshallstartfromtheday______thebusinesslicenseofthecompanyisissued.
Evenachildknowsthatnoddingheadmeans"Yes".Butsomepeoplewouldprobably【56】whentheyfirstcametoIndia.Whentheytal
关于CT密度分辨率测试的表述,正确的是
在火灾自动报警系统中,开关量和模拟量两种原理探测器的不同之处有()。
企业因解除与职工的劳动关系给予职工补偿而发生的职工薪酬,应借记()科目。
奥苏贝尔提倡在教学中采用“先行组织者”这一技术,其精神实质是()
无线网络技术已经成为当前的一种主流技术,并且呈现出快速演进的趋势。_______属于4G无线网络技术的标准。
Livinginacityhasbothadvantagesanddisadvantages.Ontheplusside,itisoften【C1】______tofindwork,andthereisusuall
ChoosethemostsuitableheadingsforparagraphsB-Efromthelistofheadingsbelow.Writetheappropriatenumbersi-ixinboxes
最新回复
(
0
)