Professional Documents
Culture Documents
Nandini Project
Nandini Project
Compiler and Interpreter are the terms related with language transition.
if Statement:
You can use if statement to check a specific condition. It performs a course of action if the
condition is true, otherwise the action is ignored.
if the condition is true then both the statements are executed. But if the condition is false,
the control ignores the statements and is passed to the next line of the program.
SYNTAX:
if(condition 1)
{
Statement 1
Statement 2
}
if-else
You can use if-else statement in a logical situations when either of the 2 actions are to be
performed depending upon certain conditions .it operates one set of statements or other
depending on the given condition is true or false respectively.
SYNTAX:
if(condition 1)
{
Statement 1
}
else
{
Statement 2
}
IF-ELSE IF
It is where more than two actions are to be taken depending upon the conditions with the
keyword ‘else if’. When the ‘condition 1’ is true then it perform statement 1 in case
‘condition 1’ is false then the control enters else's parts and check the condition to further
this statement to our statement 3 is executed depending on condition to is true or false
respectively.
SYNTAX:
if(condition 1)
{
Statement 1
}
else if(condition 2)
{
Statement 2
}
else
{
Statement 3
}
NESTED IF:
When if statement is placed within another if statement it is known as nested if statement
it can be done by using if-else if structure.
SYNTAX:
if(condition 1)
{
if(condition 2)
Statement 1
else
Statement 2
}
else
{
if(condition 3)
Statement 3
else
Statement 4
}