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
  • Write a program that check odd / even numbers (from number 1 to 100). Display the...

    Write a program that check odd / even numbers (from number 1 to 100). Display the results within an HTML table with 2 columns: one for odd number and one for even numbers. NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...

  • Write a program with loops that compute a.The sum of all even numbers between 2 and...

    Write a program with loops that compute a.The sum of all even numbers between 2 and 100 (inclusive). b.The sum of all squares between 1 and 100 (inclusive). c.All powers of 2 from 20 up to 220. d.The sum of all odd numbers between a and b (inclusive), where a and b are inputs. Note*: For part d, enter 3 and 21 as input Output should be: a. 2550 b. 338350 c. 1.0 2.0 4.0 8.0 ... 1048576.05 d. 120

  • Php

    Write a php program to print the even numbers between 50 and 100 

  • Write a C++ program to read four whole numbers (integers) and perform the following (1) Display...

    Write a C++ program to read four whole numbers (integers) and perform the following (1) Display the largest of the numbers (2) Display the smallest of the numbers (3) Display sum of the even numbers (4) Display number of even and odd numbers

  • Write a for loop that prints out all the even numbers between 100 and 2 in...

    Write a for loop that prints out all the even numbers between 100 and 2 in reverse order, i.e., 100, 98, 96, etc. (4 Points) NOTE: Write just the for loop no classes or methods such as main.

  • Javascript Write a program to generate random numbers between a user-specified range, then count and display...

    Javascript Write a program to generate random numbers between a user-specified range, then count and display the frequencies of the most / least appeared numbers. Sample Output How many random numbers? 1000000 Enter the minimum number: 100 Enter the maximum number: 200 Generated 1000000 random numbers between 100 (inclusive) and 200 (exclusive). Number 133 has the most occurrences (10197). Number 154 has the least occurrences (9749).

  • Write a program using the LOOP instruction to sum all the even numbers from 20H to...

    Write a program using the LOOP instruction to sum all the even numbers from 20H to 80H. Write a program using the ADC (or add with carry) instruction to add these two 48 bit numbers. Assume the first number is store at an address starting 400H and that the second number is stored at an address starting at address 500H. Store the results in memory starting at address 600H. (Note that each number consists of three 16 bit words). Show...

  • Q3). Write a C program to compute and display maximum of three numbers using a function...

    Q3). Write a C program to compute and display maximum of three numbers using a function for maximum of two numbers. Sample Output: Input: 5153 Maximum = 15 Q4). Write a C program to input a lowercase alphabet character then display it as uppercase character. SAMPLE OUTPUT: Enter any a lowercase character: a Uppercase: A

  • 2. Write a PHP program that will display a form containing two fields: username and password,...

    2. Write a PHP program that will display a form containing two fields: username and password, a submit button. Upon submission of the form, check the validity of the username and password. Display a welcome message if the username and password is valid else displays any error message. [3 Marks] e hp

  • 1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores...

    1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores them into an array. The program then calculates the average and displays the average and the numbers that are above the average. Use loops where needed. Must be stored in an array. Must be done using C++. 2. Write a program that reads 8 student scores, between 0 and 100, finds the best score, and then assigns grades based on the following scheme. Must...

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
ADVERTISEMENT