SlideShare a Scribd company logo
Chapter 7
Java Basics
Part 3 Control Structures
Presented by nuzhat memon
- Branches (if statement & switch statement)
- Loops (for, while, do while)
- Break and Continue Statement
Presented by Nuzhat Memon
Block statement
+ A block statement is a group of statements enclosed between a pair of braces, { and }
+ Block can be used for various purpose as follows:
 To group a sequence of statements into a unit that is to be treated as a single statement.
 To group logically related statements.
 To create variables with local scope for statements within a block.
2
SwapNo:
{ // start of block
int a=10, b=20;
System.out.println(“Value of a is “+a);
System.out.println(“Value of b is “+b);
int temp=a;
a=b;
b=temp;
System.out.println(“Now value of a is “+a);
System.out.println(“Now value of b is “+b);
} // end of block
Presented by Nuzhat Memon 3
branches/decision/selective
Control Structures
loops
Do while loop
For loop While loop
If statement Switch case
In general, the statements are executed sequentially, one by one. Sometimes,
program logic needs to change the flow of this sequence.
The statements that enable to control the flow of execution are considered as
control structures
Control Structures
Presented by Nuzhat Memon
Branches (or Decision or selective structure)
Branches are used to choose among two or more possible courses of action,
also called decision or selective structure
(1) IF STATEMENT
 Used in a program to take one of two alternative coursed of action,
depending upon Boolean valued expression.
 When if statement is executed, it first evaluates boolean expression
 If its value is true, it executes statement1;
 Otherwise it executes statement2 written after keyword else
(2) SWITCH STATEMENT
 Used when there are many alternative actions to be taken depending
upon the value of a variable or expression.
 Test expression should be of the type byte, char, short or int or enum
 This test expression is compared with each of the case values.
 If a match is found, the following statement is executed.
 If no match is found, the default statement is executed.
4
if(boolean expression){
statement1;
}
Else{
statement2;
}
Switch (expression){
case 1:
statement1;
break;
case 2:
statement2;
break;
default:
statementN;
}
Presented by Nuzhat Memon 5
Entry controlled or pre-test
loop constructs.
It is used when numbers of
iterations are pre-defined.
Entry controlled or pre-test
loop constructs.
It is used when number of
iterations are not
pre-determined.
Exit controlled or post-test
loop constructs.
Here, statements of loop are
executed at least once.
Do while loop
Looping
For loop While loop
for (initialize; condition; iteration){
statements;
}
//initialize
while (condition){
statements;
increment/decrement statement;
}
//initialize
Do{
statements;
incr/decr statement;
} while (condition);
 Loops are used to repeat a sequence of statements over and over until some
condition occurs. Loop are executed if condition is true.
 Java supports 3 types of looping constructs:
Looping (Repetitive Control Structures)
Presented by Nuzhat Memon
Questions:
 Which of the following is compiled error free?
(A)for(;;){int i=7}; (B) while (1) { int i=7};
(C) while (true){int i=7} (D) All of these
 What will be output of following program?
class abc{
public static void main(string[] S){
for(int i=0;i<10;i++){
SYSTEM.out.println(i);
}
}
}
(A) error (B) i (C) Display 1 to 10 (D) 1,2,3,…….10
6
Presented by Nuzhat Memon
Statement
BREAK STATEMENT
+ Used to transfer the control outside switch/loop
structure.
+ It is used to exit the loop.
+ It is jumps outside the nearest loop containing
this statement.
CONTINUE STATEMENT
+ It is used to skip the following statement in a loop
and continue with the next iteration.
7
for(){
if(condition){
break;
}
statementss;
}
for(){
if(condition){
continue;
}
statements;
}
Presented by Nuzhat Memon
Thanks!
Any questions?
You can find me at:
+ nuzhatmemon.com
+ nuzhat.memon@gmail.com
8

More Related Content

What's hot

(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
Frank Nielsen
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
PRN USM
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
Jaya Kumari
 
Control Structures: Part 1
Control Structures: Part 1Control Structures: Part 1
Control Structures: Part 1
Andy Juan Sarango Veliz
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Java Decision Control
Java Decision ControlJava Decision Control
Java Decision Control
Jayfee Ramos
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in JavaRavi_Kant_Sahu
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
Tech
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 
Control Structure in C
Control Structure in CControl Structure in C
Control Structure in C
Neel Shah
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Looping statements
Looping statementsLooping statements
Looping statements
Jaya Kumari
 
Control statements in java programmng
Control statements in java programmngControl statements in java programmng
Control statements in java programmng
Savitribai Phule Pune University
 
Control structures selection
Control structures   selectionControl structures   selection
Control structures selection
Online
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java Statements
It Academy
 

What's hot (20)

(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 2) A Concise and Practical Introduction to Programming Algorithms in...
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Control statement-Selective
Control statement-SelectiveControl statement-Selective
Control statement-Selective
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
 
Control Structures: Part 1
Control Structures: Part 1Control Structures: Part 1
Control Structures: Part 1
 
07 flow control
07   flow control07   flow control
07 flow control
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Java Decision Control
Java Decision ControlJava Decision Control
Java Decision Control
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
Control Structure in C
Control Structure in CControl Structure in C
Control Structure in C
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Control statements in java programmng
Control statements in java programmngControl statements in java programmng
Control statements in java programmng
 
Control structures selection
Control structures   selectionControl structures   selection
Control structures selection
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java Statements
 

Similar to Std 12 computer java basics part 3 control structure

Control statements
Control statementsControl statements
Control statements
CutyChhaya
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
TANUJ ⠀
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
JavvajiVenkat
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
Shahzu2
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
SKUP1
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
LECO9
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
farantouqeer8
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 
C language 2
C language 2C language 2
C language 2
Arafat Bin Reza
 
Chapter05-Control Structures.pptx
Chapter05-Control Structures.pptxChapter05-Control Structures.pptx
Chapter05-Control Structures.pptx
AdrianVANTOPINA
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
Niket Chandrawanshi
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
SHRIRANG PINJARKAR
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
Rai University
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
Rai University
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statements
Rai University
 
Flow of control
Flow of controlFlow of control
Flow of control
Shobhit Singhal
 
UNIT 2 PPT.pdf
UNIT 2 PPT.pdfUNIT 2 PPT.pdf
UNIT 2 PPT.pdf
DhanushKumar610673
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, Looping
MURALIDHAR R
 
Diploma ii cfpc u-3 handling input output and control statements
Diploma ii  cfpc u-3 handling input output and control statementsDiploma ii  cfpc u-3 handling input output and control statements
Diploma ii cfpc u-3 handling input output and control statements
Rai University
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statements
Rai University
 

Similar to Std 12 computer java basics part 3 control structure (20)

Control statements
Control statementsControl statements
Control statements
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
C language 2
C language 2C language 2
C language 2
 
Chapter05-Control Structures.pptx
Chapter05-Control Structures.pptxChapter05-Control Structures.pptx
Chapter05-Control Structures.pptx
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statements
 
Flow of control
Flow of controlFlow of control
Flow of control
 
UNIT 2 PPT.pdf
UNIT 2 PPT.pdfUNIT 2 PPT.pdf
UNIT 2 PPT.pdf
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, Looping
 
Diploma ii cfpc u-3 handling input output and control statements
Diploma ii  cfpc u-3 handling input output and control statementsDiploma ii  cfpc u-3 handling input output and control statements
Diploma ii cfpc u-3 handling input output and control statements
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statements
 

More from Nuzhat Memon

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQs
Nuzhat Memon
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQs
Nuzhat Memon
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQs
Nuzhat Memon
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
Nuzhat Memon
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqs
Nuzhat Memon
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)
Nuzhat Memon
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Nuzhat Memon
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Nuzhat Memon
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Nuzhat Memon
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
Nuzhat Memon
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Nuzhat Memon
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Nuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to Layers
Nuzhat Memon
 

More from Nuzhat Memon (20)

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQs
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQs
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQs
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqs
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
 
Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)Std 12 computer chapter 6 object oriented concepts (part 2)
Std 12 computer chapter 6 object oriented concepts (part 2)
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to Layers
 

Recently uploaded

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 

Std 12 computer java basics part 3 control structure

  • 1. Chapter 7 Java Basics Part 3 Control Structures Presented by nuzhat memon - Branches (if statement & switch statement) - Loops (for, while, do while) - Break and Continue Statement
  • 2. Presented by Nuzhat Memon Block statement + A block statement is a group of statements enclosed between a pair of braces, { and } + Block can be used for various purpose as follows:  To group a sequence of statements into a unit that is to be treated as a single statement.  To group logically related statements.  To create variables with local scope for statements within a block. 2 SwapNo: { // start of block int a=10, b=20; System.out.println(“Value of a is “+a); System.out.println(“Value of b is “+b); int temp=a; a=b; b=temp; System.out.println(“Now value of a is “+a); System.out.println(“Now value of b is “+b); } // end of block
  • 3. Presented by Nuzhat Memon 3 branches/decision/selective Control Structures loops Do while loop For loop While loop If statement Switch case In general, the statements are executed sequentially, one by one. Sometimes, program logic needs to change the flow of this sequence. The statements that enable to control the flow of execution are considered as control structures Control Structures
  • 4. Presented by Nuzhat Memon Branches (or Decision or selective structure) Branches are used to choose among two or more possible courses of action, also called decision or selective structure (1) IF STATEMENT  Used in a program to take one of two alternative coursed of action, depending upon Boolean valued expression.  When if statement is executed, it first evaluates boolean expression  If its value is true, it executes statement1;  Otherwise it executes statement2 written after keyword else (2) SWITCH STATEMENT  Used when there are many alternative actions to be taken depending upon the value of a variable or expression.  Test expression should be of the type byte, char, short or int or enum  This test expression is compared with each of the case values.  If a match is found, the following statement is executed.  If no match is found, the default statement is executed. 4 if(boolean expression){ statement1; } Else{ statement2; } Switch (expression){ case 1: statement1; break; case 2: statement2; break; default: statementN; }
  • 5. Presented by Nuzhat Memon 5 Entry controlled or pre-test loop constructs. It is used when numbers of iterations are pre-defined. Entry controlled or pre-test loop constructs. It is used when number of iterations are not pre-determined. Exit controlled or post-test loop constructs. Here, statements of loop are executed at least once. Do while loop Looping For loop While loop for (initialize; condition; iteration){ statements; } //initialize while (condition){ statements; increment/decrement statement; } //initialize Do{ statements; incr/decr statement; } while (condition);  Loops are used to repeat a sequence of statements over and over until some condition occurs. Loop are executed if condition is true.  Java supports 3 types of looping constructs: Looping (Repetitive Control Structures)
  • 6. Presented by Nuzhat Memon Questions:  Which of the following is compiled error free? (A)for(;;){int i=7}; (B) while (1) { int i=7}; (C) while (true){int i=7} (D) All of these  What will be output of following program? class abc{ public static void main(string[] S){ for(int i=0;i<10;i++){ SYSTEM.out.println(i); } } } (A) error (B) i (C) Display 1 to 10 (D) 1,2,3,…….10 6
  • 7. Presented by Nuzhat Memon Statement BREAK STATEMENT + Used to transfer the control outside switch/loop structure. + It is used to exit the loop. + It is jumps outside the nearest loop containing this statement. CONTINUE STATEMENT + It is used to skip the following statement in a loop and continue with the next iteration. 7 for(){ if(condition){ break; } statementss; } for(){ if(condition){ continue; } statements; }
  • 8. Presented by Nuzhat Memon Thanks! Any questions? You can find me at: + nuzhatmemon.com + nuzhat.memon@gmail.com 8