Tuesday 30 March 2021

1,2,4,7,11,16...n series in php step by step

 1,2,4,7,11,16...n in PHP



<?php

/* 1,2,4,7,11,16...n. */

$l=1;

$a=1;

$b=1;

while($l<=10)

{

print"<br>".$a;

$a=$b+$a;

$b++;

$l++;

}

?>


 


1,1,2,3,5,8,13,21....n || Fibonacci series in php

 1,1,2,3,5,8,13,21....n Series in PHP Example



<?php

/* 1,1,2,3,5,8,13,21....n. */

$a=1;

$b=0;

$c=0;

$l=1;

while($l<=10)

{

$c=$a+$b;

print"<br>".$c;

$a=$b;

$b=$c;

$l++;

}

?>


Write a program to print square and also print sum of the number ||

 Print square and also print sum of the number in PHP


<?php
/* Write a program to print square and also print sum of the number.*/
$a=1;
$b=0;
$sum=0;
while($a<=10)
{
$b=$a*$a;
print"<br>".$b;
$sum=$sum+$b;
$a++;
}
print"<br>Sum = ".$sum;
?>


1,4,9,16,25,36 in php || sum of series in php program

 

SUM OF SERIES IN PHP

<?php

/* 1,4,9,16,25,36....n.*/

$a=1;

$b=0;

while($a<=10)

{

$b=$a*$a;

print"<br>".$b;

$a++;

}

?>


OUTPUT : 1,4,9,16,25,36

Friday 19 March 2021

check enter value if character or digit or Special Symbol using php

 check enter value if character or digit or Special Symbol using php



<title>check enter value if character or digit or Special Symbol using php</title>

<?php
/* Enter a character and display a message on the screen telling the user 
wether the character is an alphabet or digit or any other special character.*/
$a=0;
if($a>='0' && $a<='9')
{
print"Digit";
}
if($a>='a' && $a<='z' | $a>='A' && $a<='Z')
{
print"Alphabet";
}
else
{
print"Special Symbol";
}
?>

Write a program to Find Vowel or Not Vowel in PHP

 

Write a program to Find Vowel or Not Vowel in PHP


<title>Write a program to Find Vowel or Not Vowel in PHP</title>

</head>

<body>

<?php

/* Write a program to get the one character from user and find out

this character is vowel or not.*/

 $x='a';

if($x=='a'|$x=='e'|$x=='i'|$x=='o'|$x=='u'|$x=='A'|$x=='E'|$x=='I'|$x=='O'|$x=='U')

 {

print"Vowel";

}

else

{

print"Not Vowel";

}

?>



Thursday 18 March 2021

Write a program to accept any year four digits and check whether it is leap year or not

 Write a program to accept any year four digits and check whether it is leap year or not


<title>Write a program to accept any year four digits and check whether it is leap year or not</title>


<?php

/* Write a program to accept any year four digits and check 

whether it is leap year or not.*/

$y=2000;

if($y%4==0)

{

print"Leap Year";

}

else

{

print"Not Leap Year";

}

?>


Write a program to accept any number and check wether it is divisible by 9 ot not

Write a program to accept any number and check wether it is divisible by 9 ot not 


<title>Write a program to accept any number and check wether it is  divisible by 9 ot not</title>

<?php

/* Write a program to accept any number and check wether it is 

divisible by 9 ot not.*/

$n=3;

if($n%9==0)

{

print"Divisible";

}

else

{

print"Not Divisible";

}

?>


Thursday 4 March 2021

Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list in PHP

Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list In PHP


Example:


<title>PHP:Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list </title>


<?php

/* Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list.*/

$n=array(1,2,9,4,5,9,7,8,9,10,9);

$sv=9;

$count=0;

for($a=1;$a<=10;$a++)

{

if($n[$a]==$sv)

{

$count++;

}

}

print"Searching values is found times = ".$count."<br>";

?>


</body>

</html>

OUTPUT:

Searching values is found times = 4

Write a program that reads 10 element in array count how many zero how many positive and how many negative values in php

 

<title>PHP : Write a program that reads 10 element in array count how many zero how many positive and how many negative values</title>

EXAMPLE:

<?php

/* Write a program that reads 10 element in array count how many zero how many positive and how many negative values.*/

$n=array(1,-2,3,-4,5,-6,7,8,9,10,0);

$b=0;

$c=0;

$d=0;

for($a=1;$a<=10;$a++)

{

if($n[$a]<0)

{

$b++;

}

if($n[$a]>0)

{

$c++;

}

if($n[$a]==0)

{

$d++;

}

}

print"Positive Number = ".$b."<br>";

print"negative Number = ".$c."<br>";

print"Zero Number = ".$d;

?>

OUTPUT:

Positive Number = 3
negative Number = 6
Zero Number = 1



Write a program that reads 10 element in array count how many odd values and how many even values in the list in php

Write a program that reads 10 element in array count how many odd values and how many even values in the list in php


Example:


<title>PHP: Write a program that reads 10 element in array count how many odd values and how many even values in the list in php</title>

<?php
/* Write a program that reads 10 element in array count how many odd values
and how many even values in the list.*/
$n=array(2,1,4,6,10,12,13,14,15,16,17);
$b=0;
$c=0;
for($a=1;$a<=10;$a++)
{
if($n[$a]%2==0 or $n[$a]==0)
{
$c++;
}
else
{
$b++;
}
}
print"Odd Number = ".$b."<br>";
print"Even Number = ".$c;
?>


Output:

Odd Number = 4
Even Number = 6

Write a program that reads 10 element and print all even values form them Using PHP

 Write a program that reads 10 element and print all even values form them Using PHP


Example:


<title>PHP: Write a program that reads 10 element and print all even values form them Using PHP</title>


<?php

/* Write a program that reads 10 element and print all even values form them.*/

$n=array(1,2,3,4,5,6,7,8,9,10);

for($a=1;$a<=10;$a++)

{

if($n[$a]%2==0)

{

print"<br>"."Odd Number = ".$n[$a];

}

}

?>


OUTPUT:

Even Number = 2
Even Number = 4
Even Number = 6
Even Number = 8
Even Number = 10


Write a program that reads 10 element and print all odd values from them using php

 Write a program that reads 10 element and print all odd values from them using php


Example:


<title>PHP: Write a program that reads 10 element and print all odd values from them </title>


<?php

/* Write a program that reads 10 element and print all odd values from them.*/

$n=array(1,2,3,4,5,6,7,8,9,10,11);

for($a=1;$a<=10;$a++)

{

if($n[$a]%2!=0)

{

print"<br>"."Odd Number = ".$n[$a];

}

}

?>



OUTPUT:

Odd Number = 1
Odd Number = 3
Odd Number = 5
Odd Number = 7
Odd Number = 9
Odd Number = 11


Wednesday 3 March 2021

Write a program to sort array of elements using bubble sort Using PHP

 

Write a program to sort array of elements using bubble sort

Example : 



<title>PHP : Write a program to sort array of elements using bubble sort.</title>


<?php

/* Write a program to sort array of elements using bubble sort. */

$n=array(9,8,7,6,5,4,3,2,1,0);

$temp=0;

for($b=0;$b<=9;$b++)

{

if($n[$b]<$n[$b-1])

{

$temp=$n[$b];

$n[$b]=$n[$b-1];

$n[$b-1]=$temp;

}

}

print"After Sorting";

for($a=0;$a<=8;$a++)

{

print"<br>".$n[$a];

}

?>


OutPut : 

After Sorting
8
7
6
5
4
3
2
1
0

Write a program to get 10 student mark from user and sort it in ascending order using php

Write a program to get 10 student mark from user and sort it in ascending order
 

Example : 


<title>Write a program to get 10 student mark from user and sort it in ascending order</title>


<?php

/* Write a program to get 10 student mark from user and sort it in ascending order. */

$n=array(2,1,5,6,4,3,0,8,9,7);

for($a=0;$a<=9;$a++)

{

for($b=$a+1;$b<=9;$b++)

{

if($n[$a]>$n[$b])

{

$temp=$n[$a];

$n[$a]=$n[$b];

$n[$b]=$temp;

}

}

}

print"Asending Number";

for($a=0;$a<10;$a++)

{

print"<br>".$n[$a];

}

?>


Write a program to get 10 number from user & find and min number in php

Write a program to get 10 number from user & find and min number and Maximum Numbers using PHP

Example:


<?php 

// Returns maximum in array 
function getMax($array)  
   $n = count($array);  
   $max = $array[0]; 
   for ($i = 1; $i < $n; $i++)  
       if ($max < $array[$i]) 
           $max = $array[$i]; 
    return $max;        
  
// Returns maximum in array 
function getMin($array)  
   $n = count($array);  
   $min = $array[0]; 
   for ($i = 1; $i < $n; $i++)  
       if ($min > $array[$i]) 
           $min = $array[$i]; 
    return $min;        
  
// Driver code 
$array = array(1, 2, 3, 4, 5); 
echo "maximum Number : ".(getMax($array)); 
echo("<br>"); 
echo "Minimum Number : ".(getMin($array)); 
?> 

Write a program to get the 10 values for user & calculate sum and average using php

 Write a program to get the 10 values for user & calculate sum and average.

        (Learn All Programming and Scripting Languages with youtube.com/avadhtutor/playlists)
Example: 

<title>Write a program to get the 10 values for user & calculate sum and average.</title>

<?php

/* Write a program to get the 10 values for user & calculate sum and average. */
$arr1=array(1,2,3,4,5,6,7,8,9,10);
$sum=0;
foreach($arr1 as $arr2=>$arr3)
{
                print$arr3."<br>";
$sum=$sum+$arr3;
}
$avg=$sum/10;
print"Sum = ".$sum."<br>";
print"Avrage = ".$avg;

?>

Output:

1
2
3
4
5
6
7
8
9
10
Sum = 55
Avrage = 5.5