Professional Documents
Culture Documents
<a href=”https://www.teeztareen.com/2019/06/if-statement-in-java-programing.html”> if
statement in java programing </a>
Syntax of if statement.
If(condion)
{
Statement..1
Statement..2
Statement..3
}
example
If (radius>=0){
Area= radius*radius+pi
System.out.printin(“the area for the circle of radius “ +radius “is” area);}
Flowchart
Limitation of if statement.
If a statement is the simple selection structure but it is very limited in its use.
The statement or set of statement is executed if the condition is true but if the condition is the
false the nothing is happening.
A user may went for
Execute one statement or set of statement if the condition is true.
Execute the other statement and set of statement if the condition is false.
For example
Imort java.until.Scanner;
Public class SimpleDemo{
Public static void main(string[]args)
{
Scanner input= new scanner(system.in);
System.out.printin(“enter an integers:”);
Int number=input.nextint();
If(number%5==0)
System.out,printin(“hivi”)
If(number%2==0)
System.out.printin(“hivin”);
}}
Out put
<a href=”https://www.teeztareen.com/2019/06/if-statement-in-java-programing.html”> if
statement in java programing </a>