c语言带参数的主函数实例,c语言 函数的参数传递示例_isgreater()函数以及C ++中的示例...

c语言 函数的参数传递示例

C ++ isgreater()函数 (C++ isgreater() function)

isgreater() function is a library function of cmath header, it is used to check whether the given first value is greater than the second value. It accepts two values (float, double or long double) and returns 1 if the first value is greater than the second value; 0, otherwise.

isgreater()函数是cmath标头的库函数,用于检查给定的第一个值是否大于第二个值。 它接受两个值( float , double或long double ),如果第一个值大于第二个值,则返回1;否则,返回1。 0,否则。

Syntax of isgreater() function:

isgreater()函数的语法:

In C99, it has been implemented as a macro,

在C99中,它已实现为宏,

macro isgreater(x, y)

In C++11, it has been implemented as a function,

在C ++ 11中,它已作为函数实现,

bool isgreater (float x      , float y);

bool isgreater (double x     , double y);

bool isgreater (long double x, long double y);

Parameter(s):

参数:

x, y – represent the two values to be checked whether x is greater than the y. x,y –表示两个要检查的值,即x是否大于y 。

Return value:

返回值:

The returns type of this function is bool, it returns 1 if x is greater than y; 0, otherwise.

该函数的返回类型为bool ,如果x大于y ,则返回1;否则,返回1。 0,否则。

Example:

例:

Input:

float x = 10.0f;

float y = 5.0f;

Function call:

isgreater(x, y);

Output:

1

C ++代码演示isgreater()函数的示例 (C++ code to demonstrate the example of isgreater() function)

// C++ code to demonstrate the example of

// isgreater() function

#include

#include

using namespace std;

int main()

{

cout << "isgreater(0.0f, -2.0f): " << isgreater(0.0f, -2.0f) << endl;

cout << "isgreater(10.0f, 20.0f): " << isgreater(10.0f, 20.0f) << endl;

cout << "isgreater(10.0f, 5.0f): " << isgreater(10.0f, 5.0f) << endl;

cout << "isgreater(-10.0f, -20.0f): " << isgreater(-10.0f, -20.0f) << endl;

float x = 10.0f;

float y = 5.0f;

// checking using the condition

if (isgreater(x, y)) {

cout << x << " is greater than " << y << endl;

}

else {

cout << x << " is not greater than " << y << endl;

}

x = 20.0f;

y = 10.0f;

if (isgreater(x, y)) {

cout << x << " is greater than " << y << endl;

}

else {

cout << x << " is not greater than " << y << endl;

}

return 0;

}

Output

输出量

isgreater(0.0f, -2.0f): 1

isgreater(10.0f, 20.0f): 0

isgreater(10.0f, 5.0f): 1

isgreater(-10.0f, -20.0f): 1

10 is greater than 5

20 is greater than 10

Reference: C++ isgreater() function

参考: C ++ isgreater()函数

翻译自: https://www.includehelp.com/cpp-tutorial/isgreater-function-with-example.aspx

c语言 函数的参数传递示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值