两个超大整数相加_PHP程序创建查找两个整数相加的函数

两个超大整数相加

Given two numbers and we have to find their addition/sum in PHP using a user-defined function.

给定两个数字,我们必须使用用户定义的函数在PHP中找到它们的加法和/和。

PHP code:

PHP代码:

<?php
//function definition
//this function will take two integer arguments
//and return the sum of them
function addTwoNumbers(int $x, int $y)
{
    return $x + $y;
}

//calling the function and printing the result
echo " sum of 10 and 25 : " . addTwoNumbers(10, 25);
echo "<br>";
echo " sum of 30 and -10: " . addTwoNumbers(30, -10);
echo "<br>";
?>

Output

输出量

 sum of 10 and 25 : 35
 sum of 30 and -10: 20

Code explanation:

代码说明:

The function works by using the standard math operation of adding two integers. Whenever we need to call the function, we use the following format addTwoNumbers (x, y); by replacing the values of x and y with two valid integers, we get the resulting sum in the output.

该函数通过使用将两个整数相加的标准数学运算来工作。 每当需要调用该函数时,都使用以下格式addTwoNumbers(x,y); 通过用两个有效的整数替换x和y的值,我们在输出中获得结果总和。

翻译自: https://www.includehelp.com/php/create-a-function-to-find-the-addition-of-two-integer-numbers.aspx

两个超大整数相加

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值