Write a program in PHP to to calculate the summation/subtraction/multiplication/division of two integer numbers by calling user-defined functions and display the result on computer screen display

in WORLD OF XPILAR4 years ago

coding.jpg

Problem: Write a program in PHP to to calculate the summation/subtraction/multiplication/division of two integer numbers by calling user-defined functions and display the result on computer screen display


This program demonstrates how to create & use user-defined functions in PHP language.

Code

    <!DOCTYPE html>
    <Write a program in PHP to to calculate the summation/subtraction/multiplication/division of two integer numbers by calling user-defined functions and display the result on computer screen display>
    <html>
    <body>
    
    <?php
    //php code starting from here
    
    $numb1; $numb2; //local variable declaration
    $result;
    
    $numb1 =98;
    $numb2 =569;

    //User-defined function to add two integer numbers
    function add($argument_1, $argument_2)
       {
        $return_value = $argument_1 + $argument_2;
        return($return_value);
       }
    
    $result = add($numb1, $numb2);
    print $result;
    print "<br>";
    
    //User-defined function to subtract two integer numbers
    function subtract($argument_1, $argument_2)
       {
        $return_value = $argument_1 - $argument_2;
        return($return_value);
       }
    
    $result = subtract($numb1, $numb2);
    print $result;
    print "<br>";
    
    //User-defined function to multiply two integer numbers
    function multiply($argument_1, $argument_2)
       {
        $return_value = $argument_1 * $argument_2;
        return($return_value);
       }
    
    $result = multiply($numb1, $numb2);
    print $result;
    print "<br>";
    
    //User-defined function to calculate division of two integer numbers
    function divide($argument_1, $argument_2)
       {
        $return_value = $argument_1 / $argument_2;
        return($return_value);
       }
    
    $result = divide($numb1, $numb2);
    print $result;
    
    
    //end of php code
    ?> 
    
    </body>
    </html>


Output

667  
-471  
55762  
0.17223198594025


Do it yourself on online PHP compiler: https://onecompiler.com/php

Or, download PHP ver 8.0
Download php Windows 7, 8, 8.1 and Windows 10 (32-64 bit)

Tomorrow I'll post another php problem with solution.
Have a nice day.
Thank you very much.

Coin Marketplace

STEEM 0.08
TRX 0.29
JST 0.035
BTC 108281.63
ETH 3800.86
USDT 1.00
SBD 0.58