>> Fibonacci series programe.
$f0 = 0;
$f1 = 1;
echo $f0."<br/>";
echo $f1."<br/>";
for($i=2; $i<10; $i++) {
$f2 = $f1 + $f0;
echo $f2."<br/>";
$f0 = $f1;
$f1 = $f2;
}
Output: 0 1 1 2 3 5 8 13 21 34
OR
$f0 = 0;
$f1 = 1;
for($i=0; $i<10; $i++) {
$f2 = $f1 + $f0;
echo $f0."<br/>";
$f0 = $f1;
$f1 = $f2;
}
OR
$i = $n = $t1 = 0;
$t2 = 1;
$nextTerm = 0;
$n = 10;
echo "Fibonacci Series: <br/><br/>";
for ($i = 1; $i <= $n; ++$i) {
echo $t1.' ';
$nextTerm = $t1 + $t2;
$t1 = $t2;
$t2 = $nextTerm;
}
Output: 0 1 1 2 3 5 8 13 21 34
>> Prime number programe?
>> Diamond pattern print?
>> 90 degree triangle print
>> Program to create visiting card using gd library in php?
>> Month last day salary if not Sat, Sun if yes than salary on Friday?
>> Xento machine test print count of repeated value without using an array function?
$f0 = 0;
$f1 = 1;
echo $f0."<br/>";
echo $f1."<br/>";
for($i=2; $i<10; $i++) {
$f2 = $f1 + $f0;
echo $f2."<br/>";
$f0 = $f1;
$f1 = $f2;
}
Output: 0 1 1 2 3 5 8 13 21 34
OR
$f0 = 0;
$f1 = 1;
for($i=0; $i<10; $i++) {
$f2 = $f1 + $f0;
echo $f0."<br/>";
$f0 = $f1;
$f1 = $f2;
}
OR
$i = $n = $t1 = 0;
$t2 = 1;
$nextTerm = 0;
$n = 10;
echo "Fibonacci Series: <br/><br/>";
for ($i = 1; $i <= $n; ++$i) {
echo $t1.' ';
$nextTerm = $t1 + $t2;
$t1 = $t2;
$t2 = $nextTerm;
}
Output: 0 1 1 2 3 5 8 13 21 34
>> Prime number programe?
<?php
for($i=1;$i<=100;$i++) {
$a = 0;
for($j=1;$j<=$i;$j++) {
if($i%$j == 0) {
$a++;
}
}
if($a == 2){
echo "Prime number is ".$i."<br>";
}
}
//Output: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 |
>> Diamond pattern print?
<?php for ($i = 1; $i <= 4; $i++) { for ($j = (4 - $i); $j >= 1; $j--) { echo " "; } for ($j = $i; $j >= 1; $j--) { echo "*"; } for ($j = 1; $j < $i; $j++) { echo "*"; } echo "\r"; } for ($i = 3; $i >= 1; $i--) { for ($j = (4 - $i); $j >= 1; $j--) { echo " "; } for ($j = $i; $j >= 1; $j--) { echo "*"; } for ($j = 1; $j < $i; $j++) { echo "*"; } echo "\r"; } |
>> 90 degree triangle print
<?php
for ($i = 1; $i <= 4; $i++) {
for ($j = (4 - $i); $j >= 1; $j--) { echo " "; }
for ($j = $i; $j >= 1; $j--) { echo "*"; }
echo "\r";
} |
>> Program to create visiting card using gd library in php?
>> Month last day salary if not Sat, Sun if yes than salary on Friday?
<?php error_reporting(E_ALL); $mysqli = new mysqli('localhost','root','','test'); if($mysqli->connect_errno){ echo "error".$mysqli->connect_error; } $start = $month = strtotime('2017-12-01'); $end = strtotime('2018-12-01'); while($month <= $end) { echo $day = date("D", strtotime(date('Y-m-t', $month))); echo $date = date('Y-m-t', $month); if($day == 'Sun'){ $date = date('Y-m-d', strtotime('-2 day', strtotime($date))); } if($day == 'Sat'){ $date = date('Y-m-d', strtotime('-1 day', strtotime($date))); } echo "<br>Salary Date For Employee is ". $date."<br>"; $month = strtotime("+1 month", $month); $sql = "INSERT INTO `test`.`employee` (`id` ,`name` ,`salary` ,`salarydate`) VALUES (NULL , 'amit', '1000', '$date')"; //$res = $mysqli->query($sql); } |
>> Xento machine test print count of repeated value without using an array function?
<?php $result = array(); foreach($arrintValue as $item) { if(isset($result[$item])) { $result[$item]++; }else { $result[$item] = 1; } } return $result; } $arrayCount = countArrayElement($array); print_r($arrayCount); //Desired Output Array ( [5] => 2 [6] => 1 [4] => 2 [2] => 1 [1] => 1 ) |
Comments
Post a Comment