首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> #include<stdlib.h> int fun(int n) { int*p; p=(int*)malloc(sizeof(int));
有以下程序: #include<stdio.h> #include<stdlib.h> int fun(int n) { int*p; p=(int*)malloc(sizeof(int));
admin
2020-10-26
35
问题
有以下程序:
#include<stdio.h>
#include<stdlib.h>
int fun(int n)
{
int*p;
p=(int*)malloc(sizeof(int));
*p=n;return*p;
}
main()
{
int a;
a=fun(10):
printf("%d\n",a+fun(10));
}
程序运行的结果是( )。
选项
A、0
B、10
C、20
D、出错
答案
C
解析
fun函数的功能是申请一个指针p,把p指向的存储空间赋值为n,并返回p指向的空间的值,即为n。fun(10)的返回值为10,所以a=fun(10)后a的值为10,a+fun(10)=20。
转载请注明原文地址:https://www.kaotiyun.com/show/0R3p777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列关于栈叙述正确的是
有以下程序main(){unsignedchara=8,c;c=a>>3;printf("%dn",c);}程序运行后的输出结果是
设有如下的说明和定义struct{inta;char*s;}x,*p=&x;x.a=4;x.s="hello";则以下叙述中正确的是
软件生命周期可分为定义阶段,开发阶段和维护阶段。详细设计属于
有以下程序:#include<stdio.h>#include<string.h>structA{inta;charb[10];doublec;);structAf(structAt);
下列描述中,不符合良好程序设计风格要求的是()。【07年9月】
有以下程序段:charname[20];intnum;scanf("name=%sBum=%d",name,&num);当执行上述程序段,并从键盘输入:name=Lilinum=1001<回车>后,name的值为()。
若有定义语句inta,b;doublex;,则下列选项中没有错误的是()。【10年9月】
软件的生命周期是指()。
若变量已正确定义为int型,要通过语句scanf("%d,%d,%d",&a,&b,&c);给a赋值1、给b赋值2、给c赋值3,以下输入形式中错误的是(口代表一个空格符)()。【08年9月】
随机试题
女,45岁。近1年来盗汗、心悸、易怒,食量增加。检查:突眼,心率110次/分,血压126/84mmHg,甲状腺弥漫性肿大Ⅲ度,心律齐、无杂音,举手颤动明显。查血T3、T4高于正常值。诊为原发性甲亢,经抗甲状腺药物治疗后复发,拟行甲状腺双侧次全切除术。该
因各肿瘤发病的年龄分布不同,食管癌的峰型呈
"前有悬崖,后有追兵"产生的动机冲突属于
坐骨神经痛时小脑疾患时
下列关于互斥投资方案比选的表述中,正确的有()。
委托方确定旅游规划编制单位的基本方式有()。
Thecommitteewasaskedtorenderareportonthehousingsituation.
Youarealwayslate.You______latethreetimesthisweek.
Knowledgemaybeacquiredthroughconversation,watchingtelevisionortravelling,butthedeepestandmostconsistentwayisth
A、Thebenefitsofstrongbusinesscompetition.B、Aproposaltolowerthecostofproduction.C、Complaintsabouttheexpenseofm
最新回复
(
0
)