网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

试题31

以下程序的主函数中调用了在其前面定义的fun函数

#include <stdio.h>

main()

{ double a[15], k;

k=fun(a);

}

则以下选项中错误的fun函数首部是()

A.double fun(double a[15])

B.double fun(double *a)

C.double fun(double a[])

D.double fun(double a)


参考答案

更多 “ 试题31以下程序的主函数中调用了在其前面定义的fun函数#include stdio.h………main(){ double a[15], k;k=fun(a);…}则以下选项中错误的fun函数首部是()A.double fun(double a[15])B.double fun(double *a)C.double fun(double a[])D.double fun(double a) ” 相关考题
考题 编写函数fun(),它的功能是:计算和输出下列级数的和。S=1/(1×2)+1/(2×3)+…+1/(n×(n+1))例如,当n=10时,函数值为0.909091。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序;include<conio.h>include<stdio.h>double fun(int n){}main ( ){clrscr();printf("%f\n",fun(10));}

考题 编写函数fun(),它的功能是;根据以下公式求p的值,结果由函数值带回。m与n为两个正数且要求m>n。P=m!/n!(m-n)!),例如:m=12,n=8时,运行结果为495.000000。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>float fun (int m, int n){}main(){clrscr() ;printf ("p=%f\n", fun (12,8) ) ;}

考题 请编写函数fun(),该函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间有若干个空格隔开,一行的开始没有空格。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<string. h>include<stdio, h>define N 80int fun (char *s){}main ( ){char line [N];int num=0;printf ("Enter a string: \n ");gets (line);num=fun (line);printf ("The number of word is: %d\n\n ",num);}

考题 下列给定的程序中,函数fun()的功能是:求输入的两个数中较小的数。例如:输入5 10,结果为min is 5。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。[试题源程序]include <stdio.h>include <conio.h>int fun(int x, (1) ;int z;z=x<y (2) x:y;return(z);}main()int a, b, c;scanf("%d, %d\n", (3) );c=fun(a, b);printf("min is%d:, c);}

考题 国家二级(C语言)机试模拟试卷104 下列给定的程序中,函数fun()的功能是:求输入的两个数中较小的数。例如:输入5 10,结果为rain is 5。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。[试题源程序]#include<stdio.h>#include<conio.h>int fun(int x,(1)){int z;z=x<y(2)x:y;return(z);}main(){int a, b, c;scanf(%d, %d\n,(3));c=fun(a, b);printf(min is %d, c);}

考题 下列给定程序中,函数fun()的功能是计算并输出high以内的素数之和。high由主函数传给fun()函数。若high的值为 100,则函数的值为1060。请改正程序中的错误,使它能得到正确结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>int fun(int high){int sum=0,n=0,j,yes;while(high>=2){yes=1;for(j=2;j<=high/2;j++)/*************found**************/ifhigh%j==0{yes=0;break;}/*************found**************/if(yes==0){sum+=high;n++;}high--;}return sum;}main(){clrscr();printf("%d\n",fun(100));}

考题 请编写函数fun(),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。注意:部分源程序给出如下.请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>float fun (float *a, int n){}main (){float score[30]=(90.5,72,80,61.5,55},aver;aver=fun(score, 5);printf("\nAverage score is: %5.2f\n",aver);}

考题 请补充函数fun(),函数fun()的功能是求7的阶乘。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>long fun(int n){if(【 】)return(n*fun(【 】);else if(【 】)return 1;}main(){int k=7;printf("%d!=%ld\n", k, fun(k));}

考题 下列叙述中正确的是:()A.C语言程序中,main()函数必须在其它函数之前,函数内可以嵌套定义函数B.C语言程序中,main()函数的位置没有限制,函数内不可以嵌套定义函数C.C语言程序中,main()函数必须在其它函数之前,函数内不可以嵌套定义函数D.C语言程序中,main()函数必须在其它函数之后,函数内可以嵌套定义函数

考题 对下列程序段的描述正确的是()。includeint Fun(int,int)void main(){cout 对下列程序段的描述正确的是( )。 #include<iostream.h> int Fun(int,int) void main() { cout<<Fun(5,50)<<endl; } int Fun(int x,int y) { return X*X+y*y; }A.该函数定义正确,但函数调用方式错误B.该函数调用方式正确,但函数定义错误C.该函数定义和调用方式都正确D.该函数定义和调用方式都错误

考题 请编写函数fun(),它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<coio.h>include<stdio.h>define M 81int fun(char *ss,char c){}main(){ char a[M],ch;clrscr();printf("\nPlease enter a string:");gets(a);printf("\nPlease enter a char:");ch=getchar();printf("\nThe number of the char is:%d \n",fun(a,ch));}

考题 编写函数fun(),它的功能是求n以内(不包括n)同时能被3与7整除的所有自然数之和的平方根s,并做为函数值返回。例如:n为1000时,函数值应为s=153.909064。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <math.h>include <stdio.h>double fun(int n){}main(){clrscr();printf("s=%f\n", fun(1000));}

考题 请编写函数fun(),它的功能是计算下列级数和,和值由函数值返回。S=1+x+x2/2!3/3!+…/xn/n!例如,当n=10,x=0.3时,函数值为1349859。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>include<math.h>double fun(double x, int n){}main (){clrscr ();printf ("%f ",fun(0,3,10));}

考题 编写函数fun(),函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)例如:若n的值为11时,函数的值为1.833333。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>include <string.h>float fun(int n){}main(){int n;float s;clrscr();printf("\nPlease enter N: ");scanf("%d",n);s=fun(n);printf("The result is:%f\n " , s);}

考题 请编写函数fun(),它的功能是求Fibonacci数列中小于t的最大的一个数,结果由函数返回。其中Fibonacci数列F(n)的定义为F(0)=0,F(1)=1F(n)=F(n-1)+F(n-2)例如:t=1000时,函数值为987。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <math.h>include <stdio.h>int fun(int t){}main(){int n;clrscr();n=1000;printf("n=%d, f=%d\n",n, fun(n));}

考题 对下列程序段的描述正确的是( )。 include int fun(int,int); void main( 对下列程序段的描述正确的是( )。 #include<iostream.h> int fun(int,int); void main() { cout<<fun(1,2)<<endl; } int fun(int x,int y) { return x+y; }A.该函数定义正确,但函数调用方式错误B.该函数调用方式正确,但函数定义错误C.该函数定义和调用方式都正确D.该函数定义和调用方式都错误

考题 请编写函数fun(),它的功能是计算下列级数和,和值由函数值返回。S=1-x+x2(上标)/2!-x3(上标)/3!+…+ (-1*x) n(上标)/n!例如,当n=15,x=0.5时,函数值为0.606531。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>include<math.h>double fun(double x, int n){}main(){clrscr();printf("%f ",fun (0.5,15));}

考题 编写函数fun(),它的功能是求n以内(不包括n)同时能被5与11整除的所有自然数之和的平方根s,并作为函数值返回。例如:n为1000时,函数值应为s=96.979379。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <math.h>includedouble fun(int n){}main(){clrscr();printf("s=%f\n",fun(1000));}

考题 请编写函数fun(),它的功能是计算:s=(1-In(1)-In(2)-In(3)-…-1n(m))2s作为函数值返回。在C语言中可调用log(n)函数求In(n)。log函数的引用说明是double log(double x)。例如,若m的值为15,则fun()函数值为723.570801。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(int m){}main(){clrscr();printf("%f\n",fun(15));}

考题 关于下列程序段的描述中,正确的是()。 include int fun(int,int); void main() { co 关于下列程序段的描述中,正确的是( )。 #include<iostream.h> int fun(int,int); void main() { cout<<fun(1,2)<<endl; } int fun(int x,int y) { return X+y; }A.该函数定义正确,但函数调用方式错误B.该函数调用方式正确,但函数定义错误C.该函数定义和调用方式都正确D.该函数定义和调用方式都错误

考题 请编写函数fun(),该函数的功能是:计算并输出S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5)例如,若主函数从键盘给n输入20后,则输出为s=534.188884。注意;部分源程序给出如下。请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。试题程序:include <math. h>include <stdio. h>double fun(int n){}main(){int n;double s;printf("\n\nInput n: ");scanf ("%d", n);s=fun (n)printf ("\n\ns=%f\n\n", s);}

考题 请补充函数fun(),该函数的功能是计算下面公式SN的值:例如:当N=50时,SN=71.433699。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<conio.h>include<stdio.h>double fun(int n){double s=1.0,S1=0.0;int k;for(【l】;k<=n;k++){s1=s;【 】;}return【 】;}main(){int k=0;double S;clrscr();printf("\nPlease input N=");scanf("%d",k);s=fun(k);printf("\ns=%lf",s);}

考题 以下程序的主函数中调用了在其面前定义的fun函数 #includestdio.h . . . main( ) {double a[15],k; k=fun(a); . . .} 则以下选项中错误的fun函数首部是( )。 、A.double fun(double a[l5])B.double fun(double *a) 。C.double fun(double a[])D.double fun(double a)

考题 以下程序的主函数中调用了在其前面定义的fun函数#includestdio.hmain(){ double a[15],k;k=fun(a);...}则以下选项中错误的fun函数首部是A.double fun(double a[15])B.double fun(double *a)C.double fun(double a[])D.double fun(double a)

考题 在主函数main()中定义的变量都可以在其它被调函数中直接使用。

考题 问答题请编写函数fun(),该函数的功能是:计算并输出给定整数n的所有因子(不包括1和自身)之和。规定n的值不大于1000。例如,在主函数中从键盘给n输入的值为856,则输出为:sum=763。  注意:部分源程序给出如下。  请勿改动主函数main()和其他函数中的任何内容,仅在fun()函数的花括号中填入所编写的若干语句。  试题程序如下:/**********code.c**********/#include int fun(int n){}void main(){ int n,sum; printf(Input n: ); scanf(%d,n); sum=fun(n); printf(sum=%d,sum);}

考题 单选题以下程序的主函数中调用了在其前面定义的函数fun: #include … main() {  doublea[15],k;  k=fun(a);  … } 则以下选项中错误的fun函数首部是(  )。A double fun(double a[15])B double fun(double*a)C double fun(double a[])D double fun(double a)