Showing posts with label sum of even numbers. Show all posts
Showing posts with label sum of even numbers. Show all posts

Saturday, 29 June 2013

sum of even numbers

<html>
<head>
<title></title>
</head>
<body>
<?php
function even($sum=0)
{
for($i=0;$i<=100;$i++)
{
if($i%2==0)
{
echo $i;
print "<br/>";
$sum=$sum+$i;
}

}
echo "Sum of 1 to 100 even numbers are:"." ".$sum;
}
even();
?>
</body>
</html>

Print even numbers in php

<html>
<head>
<title></title>
</head>
<body>
<?php
function even()
{
for($i=0;$i<=100;$i++)
{
if($i%2==0)
{
print "<br/>";
echo $i;
}
}
}
even();
?>
</body>
</html>