• 2022-07-02
    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( );
  • B

    内容

    • 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() ;