Q1. Find The Simple Interest Where P 10000, R 3, T 4 Output
Q1. Find The Simple Interest Where P 10000, R 3, T 4 Output
Output
Q1. Find the simple interest where P=10000, R=3, T=4
Ans - <?php Output 1
$P = 10000;
The simple interest is: 1200
$R = 3;
$T = 4;
Output 2
$simple_interest = ($P * $R * $T) / 100;
Today is Thursday.
echo "The simple interest is: " . $simple_interest;
?>
$dayOfWeek = date("l");
switch ($dayOfWeek) {
case "Monday":
break;
case "Tuesday":
break;
case "Wednesday":
break;
case "Thursday":
break;
case "Friday":
break;
case "Saturday":
break;
case "Sunday":
break;
default:
?>
Q3. Swap two given numbers
Ans - <?php
$num1 = 10;
Output 3
$num2 = 20;
Before swapping: num1 = 30, num2 = 40
echo "Before swapping: num1 = " . $num1 . ", num2 = " . $num2;
A er swapping: num1 = 40, num2 = 30
$temp = $num1;
Output 4
$num1 = $num2;
The sum of digits is: 28
$num2 = $temp;
Output 5
echo "\nA er swapping: num1 = " . $num1 . ", num2 = " . $num2;
2 3 5 7 11 13 17 19 23 29 31 37 41 43
?>
47
Q4. Find the sum of digits of a given number
Ans - <?php
$num = 45865;
$sum = 0;
$sum += $digit;
?>
Ans - <?php
for ($num = 2; $num <= 50; $num++) {
if ($num % $i == 0) {
break;
if ($isPrime) {
?>
Q6. Find the factorial of a given number
Ans - <?php
Output 6
$num = 7; // Given number
The factorial of 7 is: 5040
$factorial = 1; // Variable to store the factorial
Output 7
for ($i = 1; $i <= $num; $i++) {
dlroW olleH
$factorial *= $i;
} Output 8
echo "The factorial of " . $num . " is: " . $factorial; The area of rectangle is: 50
?> The area of the square is: 25
Q7. Reverse a given string The area of the circle is 78.53981633
Ans - <?php
$reversedStr = "";
$reversedStr .= $str[$i];
?>
<?php
?>
Square
<?php
?>
Circle
<?php
?>
} Output 10
1
?> 23
Q10. Print pa ern 456
7 8 9 10
Ans - <?php
$n = 1; Output 11
11 13 15 17 19
for ($i = 0; $i < 4; $i++)
$n = $n + 1;
echo "<br/>";
?>
Q11. Find and print all odd numbers between any two numbers.
Ans - <?php
$num1 = 10;
$num2 = 20;
if ($i % 2 != 0) {
echo $i . "\n";
?>
Q12. Explicit typecast to int.
Ans - <?php
$var = "12345";
Output 12
$intVar = (int)$var;
The integer value is: 12345
echo "The integer value is: " . $intVar;
?> Output 13
Q13. Find the number of 1s in the binary form of the given number.
The number of 1’s in the binary form
Ans - <?php of 15 is: 4
$num = 15;
Output 14
$binary = decbin($num);
?>
Ans - <?php
$str = "Hello, World!";
$count = 0;
$count++;
echo "The number of uppercase le ers in the string is: " . $count;
?>