Thursday, 4 March 2021

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


No comments:

Post a Comment