Question

Write a PHP program using to display all the even numbers between 1 and 100

Write a PHP program using to display all the even numbers between 1 and 100

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

//Php code that prints the even numbers from 1 to 100
//on browser , even number on each line
<?php
for ($var = 1; $var <= 100; $var+=1)
{
    if ($var % 2 == 0)
    echo "$var \n";
}
?>

Sample output:

Note : Use open source php compiler to write the php program and compile the code

Add a comment
Answer #2

<?php 

echo 'The even number upto 100 are : ';

for($i=1; $i<=100; $i++)  

           {  

                if($i%2 == 0)  

                {

                                echo '<br>'.$i;

                }

           }

?>


answered by: utsav
Add a comment
Answer #3
write a php program that display even numbers from 0 to 100 using while loop statement
source: 56
answered by: Gedion
Add a comment
Know the answer?
Add Answer to:
Write a PHP program using to display all the even numbers between 1 and 100
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT