Professional Documents
Culture Documents
871
871
Even numbers are those which are divisible by 2. Numbers like 2,4,6,8,10, etc are
even.
Odd numbers are those which are not divisible by 2. Numbers Like 1, 3, 5, 7, 9, 11,
etc are odd.
Logic:
Take a number.
Divide it by 2.
If the remainder is 0, print number is even.
Example:
<?php
$number=1233456;
if($number%2==0)
{
echo "$number is Even Number";
}
else
{
echo "$number is Odd Number";
}
?>
Output:
PHP Even odd program 1
Even Odd Program using Form in PHP
By inserting value in a form we can check that inserted value is even or odd.
Example:
<html>
<body>
<form method="post">
Enter a number:
<input type="number" name="number">
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if($_POST){
$number = $_POST['number'];
//divide entered number by 2
//if the reminder is 0 then the number is even otherwise the number is
odd
if(($number % 2) == 0){
echo "$number is an Even number";
}else{
echo "$number is Odd number";
}
}
?>
Output:
← prev
next →
Advertisement By AdRecover
Youtube For Videos Join Our Youtube Channel: Join Now
Help Others, Please Share
facebook twitter pinterest
Learn Latest Tutorials
SoapUI tutorial
SoapUI
RPA tutorial
RPA
manual testing tutorial
Manual T.
cucumber tutorial
Cucumber
Appium tutorial
Appium
postgresql tutorial
PostgreSQL
Apache Solr Tutorial
Solr
MongoDB tutorial
MongoDB
Gimp Tutorial
Gimp
Verilog Tutorial
Verilog
Teradata Tutorial
Teradata
PhoneGap Tutorial
PhoneGap
Preparation
Aptitude
Aptitude
Logical Reasoning
Reasoning
Verbal Ability
Verbal A.
Interview Questions
Interview
Company Interview Questions
Company
Trending Technologies
Artificial Intelligence Tutorial
AI
AWS Tutorial
AWS
Selenium tutorial
Selenium
Cloud tutorial
Cloud
Hadoop tutorial
Hadoop
ReactJS Tutorial
ReactJS
Data Science Tutorial
D. Science
Angular 7 Tutorial
Angular 7
Blockchain Tutorial
Blockchain
Git Tutorial
Git
Machine Learning Tutorial
ML
DevOps Tutorial
DevOps
B.Tech / MCA
DBMS tutorial
DBMS
Data Structures tutorial
DS
DAA tutorial
DAA
Operating System tutorial
OS
Computer Network tutorial
C. Network
Compiler Design tutorial
Compiler D.
Computer Organization and Architecture
COA
Discrete Mathematics Tutorial
D. Math.
Ethical Hacking Tutorial
E. Hacking
Computer Graphics Tutorial
C. Graphics
Software Engineering Tutorial
Software E.
html tutorial
Web Tech.
Cyber Security tutorial
Cyber Sec.
Automata Tutorial
Automata
C Language tutorial
C
C++ tutorial
C++
Java tutorial
Java
.Net Framework tutorial
.Net
Python tutorial
Python
List of Programs
Programs
Control Systems tutorial
Control S.
Data Mining Tutorial
Data Mining
Advertisement By AdRecover