Conditional statement
It means "if" condition is true then do the work(under if block) otherwise(else) don't do it.This is called if else statement or conditional statement.
If condition is met, work will be done, else not.
Written as:
If(condition)
{block of statements }
else
{block of statements }
This is called conditional programming.
Eg. X=1000,Y=100Find the greater number. Here I hv taken easy numbers but it can also be used for big numbers Eg for income tax purposes.
If(X>Y)
{document. write("x is greater") ;}
Else
{document.write("y is greater") ;}
Program:
<html>
<head></head>
<body>
<SCRIPT LANGUAGE="JavaScript" >
int x=1000, y=100;
If(X>Y)
{document. write("x is greater") ;}
Else
{document.write("y is greater") ;}
</script>
</body>
</html>
Save the file as greatest. html
Double click file for opening it.
It means "if" condition is true then do the work(under if block) otherwise(else) don't do it.This is called if else statement or conditional statement.
If condition is met, work will be done, else not.
Written as:
If(condition)
{block of statements }
else
{block of statements }
This is called conditional programming.
Eg. X=1000,Y=100Find the greater number. Here I hv taken easy numbers but it can also be used for big numbers Eg for income tax purposes.
If(X>Y)
{document. write("x is greater") ;}
Else
{document.write("y is greater") ;}
Program:
<html>
<head></head>
<body>
<SCRIPT LANGUAGE="JavaScript" >
int x=1000, y=100;
If(X>Y)
{document. write("x is greater") ;}
Else
{document.write("y is greater") ;}
</script>
</body>
</html>
Save the file as greatest. html
Double click file for opening it.