Decision Making Statements
PRESENTED BY –
VISHAL
REG. NO. – 231302215
B.TECH CSE CYBER SECURITY
If Statement
The if statement is the
most simple decision-
making statement. The if
statement allows us to
execute a block of code
only when specified
condition is true otherwise
it will not execute.
If Statement Syntax
if(Condition)
{
//Statements to execute if condition is true
}
If Statement Example
public class IfStatementExample {
public static void main(String[] args) {
int age = 18;
if (age >= 18) {
System.out.println("You are eligible to vote!");
}
}
}
If-else Statement
The “if-else” statement in Java is
another decision-making
statement that allows you to
execute different blocks of
code based on the condition’s
result. It provides an alternative
statement to execute when
the condition is not true.
If-else Statement Syntax
if(condition) {
//code to be executed if the condition is true
}
else {
//code to be executed if the condition is false
}
Example
public class IfElse {
public static void main(String[] args) {
int n = 10;
if (n > 5) {
System.out.println("The number is greater than 5.");
}
else {
System.out.println("The number is 5 or less.");
}
}
}
Else - if ladder
 The Java if-else-if ladder is
used to evaluate multiple
conditions sequentially. It
allows a program to check
several conditions and
execute the block of code
associated with the first true
condition. If none of the
conditions are true then else
block is executed.
Else - if ladder Syntax
if (condition1) {
// Code to execute if condition1 is true
}
else if (condition2) {
// Code to execute if condition1 is false AND condition2 is true
}
else {
// Code to execute if all conditions are false
}
Else - if ladder Example
public class ElseIfLadderExample {
public static void main(String[] args) {
int marks = 78;
if (marks >= 90) {
System.out.println("Grade: A");
}
else if (marks >= 75) {
System.out.println("Grade: B");
}
else {
System.out.println("Grade: D");
}
}
}
Switch Statement
The switch statement
in Java is a multi-way
branch statement.
The Java switch
statement executes
one statement from
multiple conditions.
Switch Syntax
switch(expression){
case value1 :
// Statements
break; // break is optional
case value2 :
// Statements
break; // break is optional
default :
// default statements
}
Switch Statement Example
public class SwitchExample {
public static void main(String[] args) {
int day = 3;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid day");
}
}
}
While Statement
The while statement in Java repeatedly executes a block of
code as long as a specified condition remains true. The
condition is evaluated before each iteration of the loop. If the
condition is initially false, the loop body will not execute at all.
Syntax :
while (condition) {
// code block to be executed
}
Example
public class WhileExample {
public static void main(String[] args) {
int i = 1;
while (i <= 5) {
System.out.println("Count: " + i);
i++;
}
}
}
For Statement
 For loop in java is a control flow statement used to execute a block
of code repeatedly for a specific number of times , based on
condition.
 For loop initializes a variable , checks a condition before each
iteration and update the variable after every iteration .
Syntax :
for (initialization; condition; increment) {
// code to be executed
}
Example
public class SumExample {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 10; i++) {
sum += i;
}
System.out.println("Sum of first 10 natural numbers is: " + sum);
}
}
THANK YOU

More Related Content

PPTX
Java Decision Control
PPTX
3-Decision making and Control structures-28-04-2023.pptx
PPTX
22AD201 – Java Programming -Decision Statements.pptx
PPTX
Control structures in java
PPTX
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
PDF
itft-Decision making and branching in java
PPTX
Java learning
PPT
_Java__Expressions__and__FlowControl.ppt
Java Decision Control
3-Decision making and Control structures-28-04-2023.pptx
22AD201 – Java Programming -Decision Statements.pptx
Control structures in java
controlStatement.pptx, CONTROL STATEMENTS IN JAVA
itft-Decision making and branching in java
Java learning
_Java__Expressions__and__FlowControl.ppt

Similar to Decision_Makoiyuhrttouehgouesygytiuojth0ueyutwaeing.pptx (20)

PPTX
control statements
PPTX
3. Java Installations ppt for engineering
PPTX
Object oriented programming_Unit1_contro statements.pptx
PPTX
Control statements in java
PPTX
Chapter 4 java
PPT
Decision Making and Branching in C
PPTX
Lecture - 5 Control Statement
PPTX
PPTX
Computer programming 2 Lesson 9
PPTX
Computer programming 2 - Lesson 7
PPTX
Java Control Statement Control Statement.pptx
PDF
Control flow statements in java web applications
PPT
Control statements
PPTX
Control Statements in Java
PDF
csj-161127083146power point presentation
PDF
Computer Programming 1 Computer programmingComputer programmingComputer progr...
PDF
java notes.pdf
PPTX
Control structures
PPTX
Programming in java - Concepts- Operators- Control statements-Expressions
PPTX
LESSON 4 Control Flow Statements in JAVA.pptx
control statements
3. Java Installations ppt for engineering
Object oriented programming_Unit1_contro statements.pptx
Control statements in java
Chapter 4 java
Decision Making and Branching in C
Lecture - 5 Control Statement
Computer programming 2 Lesson 9
Computer programming 2 - Lesson 7
Java Control Statement Control Statement.pptx
Control flow statements in java web applications
Control statements
Control Statements in Java
csj-161127083146power point presentation
Computer Programming 1 Computer programmingComputer programmingComputer progr...
java notes.pdf
Control structures
Programming in java - Concepts- Operators- Control statements-Expressions
LESSON 4 Control Flow Statements in JAVA.pptx
Ad

Recently uploaded (20)

PPTX
ELETRONIC-PRODUCTS-ASSEMBLY-AND-SERVICING-NC-II-WEEK-1-Copy.pptx
PDF
SAHIL PROdhdjejss yo yo pdf TOCOL PPT.pdf
PPTX
New professional education PROF-ED-7_103359.pptx
PDF
20A LG INR18650HJ2 3.6V 2900mAh Battery cells for Power Tools Vacuum Cleaner
PPTX
Growth Capital Investment - Espresso Capital.pptx
PDF
Maxon CINEMA 4D 2025 Crack Free Download Latest Version
PDF
PakistanCoinageAct-906.pdfdbnsshsjjsbsbb
PPTX
Chapter no 8 output devices dpart 2.pptx
PPTX
RTS MASTER DECK_Household Convergence Scorecards. Use this file copy.pptx
PDF
Tcl Scripting for EDA.pdf
PPTX
unit1d-communitypharmacy-240815170017-d032dce8.pptx
PDF
Presented by ATHUL KRISHNA.S_20250813_191657_0000.pdf
PPTX
Clauses_Part1.hshshpjzjxnznxnxnndndndndndndndnndptx
PPTX
vortex flow measurement in instrumentation
PPTX
Subordinate_Clauses_BlueGradient_Optimized.pptx
PDF
ISS2022 present sdabhsa hsdhdfahasda ssdsd
DOCX
Copy-OT LIST 12.8.25.docxjdjfufufufufuuffuf
PDF
Topic-1-Main-Features-of-Data-Processing.pdf
PPTX
Unit-1.pptxgeyeuueueu7r7r7r77r7r7r7uriruru
PDF
Dozuki_Solution-hardware minimalization.
ELETRONIC-PRODUCTS-ASSEMBLY-AND-SERVICING-NC-II-WEEK-1-Copy.pptx
SAHIL PROdhdjejss yo yo pdf TOCOL PPT.pdf
New professional education PROF-ED-7_103359.pptx
20A LG INR18650HJ2 3.6V 2900mAh Battery cells for Power Tools Vacuum Cleaner
Growth Capital Investment - Espresso Capital.pptx
Maxon CINEMA 4D 2025 Crack Free Download Latest Version
PakistanCoinageAct-906.pdfdbnsshsjjsbsbb
Chapter no 8 output devices dpart 2.pptx
RTS MASTER DECK_Household Convergence Scorecards. Use this file copy.pptx
Tcl Scripting for EDA.pdf
unit1d-communitypharmacy-240815170017-d032dce8.pptx
Presented by ATHUL KRISHNA.S_20250813_191657_0000.pdf
Clauses_Part1.hshshpjzjxnznxnxnndndndndndndndnndptx
vortex flow measurement in instrumentation
Subordinate_Clauses_BlueGradient_Optimized.pptx
ISS2022 present sdabhsa hsdhdfahasda ssdsd
Copy-OT LIST 12.8.25.docxjdjfufufufufuuffuf
Topic-1-Main-Features-of-Data-Processing.pdf
Unit-1.pptxgeyeuueueu7r7r7r77r7r7r7uriruru
Dozuki_Solution-hardware minimalization.
Ad

Decision_Makoiyuhrttouehgouesygytiuojth0ueyutwaeing.pptx

  • 1. Decision Making Statements PRESENTED BY – VISHAL REG. NO. – 231302215 B.TECH CSE CYBER SECURITY
  • 2. If Statement The if statement is the most simple decision- making statement. The if statement allows us to execute a block of code only when specified condition is true otherwise it will not execute.
  • 3. If Statement Syntax if(Condition) { //Statements to execute if condition is true }
  • 4. If Statement Example public class IfStatementExample { public static void main(String[] args) { int age = 18; if (age >= 18) { System.out.println("You are eligible to vote!"); } } }
  • 5. If-else Statement The “if-else” statement in Java is another decision-making statement that allows you to execute different blocks of code based on the condition’s result. It provides an alternative statement to execute when the condition is not true.
  • 6. If-else Statement Syntax if(condition) { //code to be executed if the condition is true } else { //code to be executed if the condition is false }
  • 7. Example public class IfElse { public static void main(String[] args) { int n = 10; if (n > 5) { System.out.println("The number is greater than 5."); } else { System.out.println("The number is 5 or less."); } } }
  • 8. Else - if ladder  The Java if-else-if ladder is used to evaluate multiple conditions sequentially. It allows a program to check several conditions and execute the block of code associated with the first true condition. If none of the conditions are true then else block is executed.
  • 9. Else - if ladder Syntax if (condition1) { // Code to execute if condition1 is true } else if (condition2) { // Code to execute if condition1 is false AND condition2 is true } else { // Code to execute if all conditions are false }
  • 10. Else - if ladder Example public class ElseIfLadderExample { public static void main(String[] args) { int marks = 78; if (marks >= 90) { System.out.println("Grade: A"); } else if (marks >= 75) { System.out.println("Grade: B"); } else { System.out.println("Grade: D"); } } }
  • 11. Switch Statement The switch statement in Java is a multi-way branch statement. The Java switch statement executes one statement from multiple conditions.
  • 12. Switch Syntax switch(expression){ case value1 : // Statements break; // break is optional case value2 : // Statements break; // break is optional default : // default statements }
  • 13. Switch Statement Example public class SwitchExample { public static void main(String[] args) { int day = 3; switch (day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday"); break; case 4: System.out.println("Thursday"); break; case 5: System.out.println("Friday"); break; case 6: System.out.println("Saturday"); break; case 7: System.out.println("Sunday"); break; default: System.out.println("Invalid day"); } } }
  • 14. While Statement The while statement in Java repeatedly executes a block of code as long as a specified condition remains true. The condition is evaluated before each iteration of the loop. If the condition is initially false, the loop body will not execute at all. Syntax : while (condition) { // code block to be executed }
  • 15. Example public class WhileExample { public static void main(String[] args) { int i = 1; while (i <= 5) { System.out.println("Count: " + i); i++; } } }
  • 16. For Statement  For loop in java is a control flow statement used to execute a block of code repeatedly for a specific number of times , based on condition.  For loop initializes a variable , checks a condition before each iteration and update the variable after every iteration . Syntax : for (initialization; condition; increment) { // code to be executed }
  • 17. Example public class SumExample { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 10; i++) { sum += i; } System.out.println("Sum of first 10 natural numbers is: " + sum); } }