更多"当使用关键字______作为函数返回类型时,该函数不返回任何值。"的相关试题:
[填空题]当使用关键字______作为函数返回类型时,该函数不返回任何值。
[填空题]为使函数不返回任何值,定义函数时应在函数名前加保留字(关键字)()。
[单项选择]下面的哪个选项不能作为函数的返回类型
A. void
B. int
C. new
D. long
[简答题]请编写函数fun( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int fun( int a [M][N])
{
}
main( )
{
int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},
{6,9,9,9,8},{1,3,5,7,0}};
int i, j, y;
clrscr( );
printf ("The original data is :/n ");
for(i=0; i<N;i++)
{for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("/n ");
}
y=fun(aa);
printf("/nThe sun:%d/n ",y);
printf("/n");
}
[简答题]编写函数proc( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+m)
例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float proc(int m)
void main( )
int m;
float s;
system ("CLS");
printf("/nPlease enter M: ");
scanf("%d", &m);
s=proc(m);
printf("The result is: %f/n", s);
[简答题]编写函数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( ),该函数的功能是:计算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);
[填空题]mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回,请填空。
int mystrlen(char*str)
int i;
for(i=0;_______!=’/0’;i++);
return(i);
[填空题]mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。
int mystrlen(char *str)
{ int i;
for(i=0; 【19】 !=’/0’;i++);
return( 【20】 );
}
[填空题]mysulen函数的功能是计算str所指字符山的长度,并作为函数值返回。请填空。
int mystrlen(Char *str)
{ int i;
for{i=0; !=’/0’;i++);
return(______);
}
[填空题]mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。
int mystrlen(char *str)
int i;
for(i=0; 【13】 !=’/0’;i++);
return( 【14】 );