Hello Guys!! How are you, all? Hope you all are well by the grace of Almighty ALLAH. Today we learn about the conditional Statement.
Conditional Code:
- The if statement.
- The if.....else statement.
- The if.....else if.....else statement.
Conditions:
- Using relational or conditional operators.
- Using logical operators.
Relational or conditional operators:
- == means 'is equal to'
- != means 'is not equal to'
- < means 'is less than'
- > means 'is greater than'
- <= means 'is less than or equal to'
- >= means 'is greater than or equal to'
Logical Operators:
- && means 'AND'
- || means 'OR'
- ! means 'NOT'
Note: Result of the condition is always wither true(1) or false(0)
Example:
1>2 Ans. 0
1<2 Ans. 1
1==2 Ans. 0
If the value of the condition is any positive or negative number except 0 or 1, it always consider that number as a true value.
The If Statement
if (condition)
{
statement;
}
Multiple statement within If
if (condition)
{
statement 1;
statement 2;
-----------;
statement n;
}
The if else statement
if (condition)
{
statement 1;
statement 2;
}
else
{
statement 1;
statement 2;
}
The if-else if-else statement
if (condition)
{
statement 1;
statement 2;
}
else if (condition)
{
statement 1;
statement 2;
}
else
{
statement 1;
statement 2;
}
Thank you all..:)
0 comments:
Post a Comment