Hướng dẫn write a php script to display quotient and remainder of the division of two variables. - viết đoạn mã php để hiển thị thương và số dư của phép chia hai biến.

Viết một chương trình để tìm thương số và phần còn lại bằng ngôn ngữ PHP. Có bạn sẽ học cách & nbsp; tìm thương số và phần còn lại bằng ngôn ngữ PHP.

Lấy một ví dụ để tìm những điều này thông qua chương trình PHP:

Output:

The Quotient is 1.76
The Remainder is 19

Tags:

# Làm thế nào để tìm phần còn lại trong ngôn ngữ PHP mà không sử dụng mô đun

# Viết chương trình PHP để tìm kích thước của int, float, double và char

# Viết một chương trình để tìm sự phân chia của hai số trong PHP

& nbsp; & nbsp;

Hướng dẫn write a php script to display quotient and remainder of the division of two variables. - viết đoạn mã php để hiển thị thương và số dư của phép chia hai biến.

Php tofind còn lại & thương học Ofanumber

& nbsp; & nbsp;
45           ÷         7           =           6           and           3
Dividend Divisor Quotient Remainder

Trong ví dụ trên, 45 là cổ tức, 7 là ước số, 6 là thương số và 3 là phần còn lại.

Vì vậy, & nbsp; phần còn lại & nbsp; là giá trị còn sót lại của người Viking sau khi chia một số nguyên cho một số nguyên khác.remainder is the “left over” value after dividing one integer by another. Quotient is the quantity produced by the division of 2 integers.

Trong PHP, chúng ta có thể đạt được điều tương tự với / và %, ví dụ: quotion = cổ tức / chia
quotion = dividend / divisor -> will give the quotient
remainder = dividend % divisor -> will give the remainder

Hãy để viết một tập lệnh PHP đơn giản để tìm phần còn lại & thương hiệu một cách linh hoạt:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

if(isset($_POST['submit'])){(isset($_POST['submit'])){

$dividend=$_POST['dividend'];=$_POST['dividend'];

$divisor=$_POST['divisor'];= $_POST['divisor'];

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành

$quotient=$dividend/$divisor;=$dividend/$divisor;

// để tìm phần còn lại sử dụng các mô -đun %

$remainder=$dividend%$divisor;=$dividend %$divisor;

}

?>

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8"/>

    <meta http-equiv="X-UA-Compatible"content="IE=edge">

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành<title>PHP tofind remainder&quotient ofanumber</title>

    <meta name="viewport"content="width=device-width, initial-scale=1">

    <!--Load Bootstrap library forbetter UI look& feel-->

    <link rel="stylesheet"type="text/css"media="screen"href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"/>

</head>

<body>

<div class="container">

<br/>

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hànhh2>PHP tofind remainder&quotient ofanumber</h2>

<br/>

<div class="row">

<div class="col-lg-4">

<div class="input-group mb-4">

<form action=""method="post">

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành<input type="number"class="form-control"name="dividend"placeholder="Base"value="(isset($dividend))? $dividend:'45';?>">

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành<div class="input-group-prepend">

// để tìm phần còn lại sử dụng các mô -đun %span class="input-group-text">/</span>

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành</div>

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành<input type="number"class="form-control"name="divisor"  placeholder="Exponent"value="(isset($divisor))? $divisor:'7';?>">

// để tìm phần còn lại sử dụng các mô -đun %<button type="submit"name="submit"class="btn btn-primary">Submit</button>

</form>

</div>

Result:div><strong>Result:</strong><br/>

<!--Print theresult-->

isset($remainder)?'Remainder: '.$remainder:'';?>

isset($quotient) ?'
Quotient: '
.round($quotient):'';?>

<div>

</div>

</div>

</div>

</body>

</html>

// để tìm sử dụng thương số /& nbsp; & nbsp; nhà điều hành

// để tìm phần còn lại sử dụng các mô -đun %

Hướng dẫn write a php script to display quotient and remainder of the division of two variables. - viết đoạn mã php để hiển thị thương và số dư của phép chia hai biến.

} 7,184

?>