Practical - 2 IWD
Aim
To write a PHP script to implement a simple calculator that performs basic mathematical operations.
Algorithm
-
Declare two numbers.
-
Select the required mathematical operation.
-
Perform the calculation using operators.
-
Display the result.
Program Code (PHP Script)
Output
Result
The PHP script successfully performed addition, subtraction, multiplication, and division using a simple calculator logic.
Viva-Related Questions
-
Which operators are used for calculations in PHP?
→+,-,*,/ -
What happens if division by zero occurs?
→ It generates a warning and returns infinity or error. -
Can user input be taken in PHP?
→ Yes, using HTML forms and PHP$_POSTor$_GET.
Comments
Post a Comment