You are on page 1of 4

NAME: SOURAV GHOSH

COURSE: BCA [5TH SEMESTER]


ROLL NUMBER: 13301221095
REG. NO.: 211331001210051[2021-2022]
PAPER NAME: INTERNET TECHNOLOGY LAB
ASSIGNMENT (PCA2)
PAPER CODE: BCAC591(500127)
UNDER THE GUIDANCE OF:
MANASH KUMAR DEB
GEORGE COLLEGE, SEALDAH
DATE: 20/10/2023
1) Write a javascript function to add , subtract, multiply, and divide any
two numbers.
=> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Javascript file</title>
</head>
<body></body>
<script type="text/javascript">
function performOperation(num1, num2, operation) {
if (typeof num1 !== 'number' || typeof num2 !== 'number') {
return "Both inputs should be numbers.";
}

switch (operation) {
case 'add':
return num1 + num2;
case 'subtract':
return num1 - num2;
case 'multiply':
return num1 * num2;
case 'divide':
if (num2 === 0) {
return "Division by zero is not allowed.";
}
return num1 / num2;
default:
return "Invalid operation. Please use 'add', 'subtract', 'multiply', or
'divide'.";
}
}

console.log("The result of addition is:",performOperation(5, 6, 'add'));


console.log("The result of subtraction:",performOperation(8, 3,
'subtract'));
console.log("The result of multiplication:",performOperation(64, 24,
'multiply'));
console.log("The result of division:",performOperation(64, 2, 'divide'));

</script>
</html>
Screenshot of the output:-

1) Write PHP code to display the current date and time.


=> <?php
$myDate = date("d-m-y h:i:s");
echo "Current date and time is :".$myDate;
?>
Screenshot of the output:-

You might also like