首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include #include int fun(int n) { int *p; p = (int*)malloc(sizeof(int)); *p=n; return *p; } main() { int a; a = fun(10)
有以下程序 #include #include int fun(int n) { int *p; p = (int*)malloc(sizeof(int)); *p=n; return *p; } main() { int a; a = fun(10)
admin
2019-05-17
51
问题
有以下程序
#include
#include
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、20
B、10
C、0
D、出错
答案
A
解析
函数fun()的功能是新分配一个存储空间并把n的值存入该存储空间内,同时返回该存储空间记录的值*p,也即是n,所以a=fun(10)=10,输出"a+fun(10)"的结果为20,答案选A。
转载请注明原文地址:https://kaotiyun.com/show/zHRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序:#include<stdio.h>#include<string.h>main(){charx[]="STRING";x[0]=0;x[1]=’\0’;x[2]=’0’;print
有以下程序:#include<stdio.h>main(){inti=5;do{if(i%3=1)if(i%
以下叙述中正确的是()。【09年9月】
支持子程序调用的数据结构是()。【09年3月】
下列数据结构中,能够按照“先进后出”原则存取数据的是()。【09年9月】
软件(程序)调试的任务是()。【10年3月】
有以下程序:#include<stdio.h>main(){FILE*pf;char*s1="China",*s2="Beijing";pf=fopen("abc.dat","wb+");fwr
以下叙述正确的是()。【10年3月】
若a是数值类型,则逻辑表达式(a==1)‖(a!=1)的值是
随机试题
开始进入新环境的物种,仅有少数能幸存下来,这些适应能力较强的植物称之为( )。
A、烂苹果味B、腐败臭味C、氨臭味D、蒜臭味E、腥臭味糖尿病酮症昏迷病人的呼气味是()
(2006年)已知函数
地下矿山发生火灾时,有多种控制措施与救护方法。下列控制措施与救护方法中,不符合地下矿山火灾事故救护的基本技术原则的是()。
根据《工程建设项目施工招标投标办法》规定,可以不进行施工招标有()。
下列不属于教师上课前的“三备”内容的是()
Manynewcomerscomplainoftherapid______oflifeinHongKong.
Dopeoplegethappierormorefoul-temperedastheyage?Stereotypesofirritableneighbors【B1】______,scientistshavebeentry
Accordingtothefirsttwoparagraphs,theauthorthinksthatWhatisNOTtrueoftheeffectivenessof"sunscreen",accordingt
"Intelligence"atbestisanassumptiveconstructthemeaningofthewordhasneverbeenclear.Thereis(41)agreementonth
最新回复
(
0
)