int area( int length, int width ){ int s; s= length * width ; return s;}有如上求长方形面积函数,正确的调用方法是( )。提示:本题area是有返回值的函数。
A: c=area(1,2);
B: area(1);
C: c=area("12","34" );
D: area( );
A: c=area(1,2);
B: area(1);
C: c=area("12","34" );
D: area( );
举一反三
- void area( int length, int width ){ int s; s= length * width ; printf(“长%d,宽%d的长方形面积是%d ”, length , width ,s);}有如上求长方形面积函数,正确的调用方法是( )。提示:本题area是无返回值的函数。 A: c=area(1,2); B: area(1,2); C: area( ); D: c=area( );
- 下列程序的输出结果为 class Box{ int length,width,height; public void setInfo(int l,int w,int h){ length = l; width = w; height = h; } public int volumn(){ return length*width*height; } public int area(){ return (length*width + length*height + width*height) * 2; } public String toString(){ return "Length:" + length + " width:" + width + " height:" + height + " volumn: " + volumn() + " area:" + area(); }} public class BoxTest { public static void main(String[] args) { Box b = new Box(); b.setInfo(5,2,4); System.out.println(b.toString()); }}
- 调用fun函数可实现求矩形的面积,补充完整以下程序。 #include void main() { _____①______; //声明函数 int area,a,b; scanf("%d,%d",&a,&b); area=______②_____; //调用fun()函数,否则不得分 printf("area=%d ",area); } int fun(int x,int y) { return(x*y); }
- 写出以下程序的输出结果为______。#define S(r) r*r void main(){int a=4,b=6; int area;area=S(a+b);printf(“area=%d”,area); } A: 100 B: 28 C: 24 D: 34
- 设有以下宏定义: #define S(x) x/x int a=4,b=3,area; 执行语句area=S(a+b);后,area的值为()