A: c=area(1,2);
B: area(1,2);
C: area( );
D: c=area( );
举一反三
- 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( );
- 下列程序的输出结果为 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(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
内容
- 0
下列哪些是正确的声明变量的方式? A: int length; int width; B: int length, width; C: int length; width; D: int length, int width;
- 1
下面程序的功能是:area函数计算圆的面积,main函数中调用area函数,计算给定半径的圆的面积,输出时显示两位小数。请填空。#include<stdio.h>#define PI 3.14 int main( ){______;float x = 2.4 , y ;y = area( x ) ; printf( "%6.2f\n" , y ) ;return 0 ;}float area ( float r ){float s ;s= PI * r * r ;_______;}
- 2
以下程序的运行结果是( )。#define PI 3#define S(x) PI*x*xmain(){ int area; area=S(2+3); printf("%d ",area);} A: 27 B: 12 C: 15 D: 75
- 3
设有以下宏定义: #define S(x) x/x int a=4,b=3,area; 执行语句area=S(a+b);后,area的值为()
- 4
【单选题】定义描述矩形的类 Rectangle ,描述长方体高的类 High ,其数据成员为长方体高度 H 。再由矩形类与高类多重派生出长方体类 Cuboid 。主函数中定义长方体对象并显示数据。 #include class Rectangle { protected: float Length,Width; // 数据成员为长与宽,类外不可访问 public: float Area() // 计算矩形面积的函数 { return Length*Width; } Rectangle(float L,float W ) { Length=L; Width=W; } Rectangle() { Length=0; Width=0; } }; class High{ private: float Height; // 数据成员为高度, public: High(float x=0) // 构造函数 { Height =x; } float GetH() { return Height; } }; class C A. Volume=Area()*GetH() ; B. Volume= Length*Width*Height ; C. Volume= Length*Width *GetH() ; D. Vol() ;