SlideShare a Scribd company logo
1 of 22
CONTROL STATEMENTS
In C Programming
1. If statement
• This is the most simple form of the branching
statements.
• It takes an expression in parenthesis and an
statement or block of statements expresses, if
the expression is true then the statement or
block of statements gets executed otherwise
these statements are skipped.
NOTE: Expression will be assumed to be true
if its evaluated values is non-zero.
11/14/2017 VIGNAN'S UNIVERSITY 2
SYNTAX
Syntax:
if (expression)
statement;
or
if (expression)
{
Block of statements;
}
11/14/2017 VIGNAN'S UNIVERSITY 3
2.If Else Statement:
• An if statement can be followed by an optional else
statement, which executes when the Boolean expression is
false.
• Syntax
if(boolean_expression)
{
statement(s);
}
Else
{
statement(s)
}
11/14/2017 VIGNAN'S UNIVERSITY 4
Flowchart of if...else statement
11/14/2017 VIGNAN'S UNIVERSITY 5
3. Nested IF....ELSE
• The if...else statement executes two different codes
depending upon whether the test expression is true
or false. Sometimes, a choice has to be made from
more than 2 possibilities.
In Nested if .....else, the if and else part can contain
one or more if else statements.
11/14/2017 VIGNAN'S UNIVERSITY 6
Syntax
if(conditional-expression)
{
if(conditional-expression)
{
statements;
}
else
{
statements;
}
statements;
}
else
{
if(conditional-expression)
{
statements;
}
statements;
}11/14/2017 VIGNAN'S UNIVERSITY 7
4. ELSE .... IF LADDER
• If we are having different – different test
conditions with different – different
statements, then for these kind of
programming we need else if leader. Else if the
leader is not interdependent to any other
statements or any other test conditions.
11/14/2017 VIGNAN'S UNIVERSITY 8
Syntax:if(test condition)
{
}
else if(condition)
{
}
else if(condition)
{
}
else
{
}
This construct is known as the else if ladder
11/14/2017 VIGNAN'S UNIVERSITY 9
ii. Switch Statement
• The switch statement is often faster than nested
if...else (not always). Also, the syntax of switch
statement is cleaner and easy to understand.
• When a case constant is found that matches the
switch expression, control of the program passes
to the block of code associated with that case.
• The break statement is used to prevent the code
running into the next case.
11/14/2017 VIGNAN'S UNIVERSITY 10
Flow Diagram
11/14/2017 VIGNAN'S UNIVERSITY 11
II. Looping
• Loops provide a way to repeat commands and
control how many times they are repeated. C
provides a number of looping way.
1. While loop
2. do...while loop
3. for loop
11/14/2017 VIGNAN'S UNIVERSITY 12
While loop
• The most basic loop in C is the while loop.A
while statement is like a repeating if
statement. Like an If statement, if the test
condition is true: the statments get executed.
The difference is that after the statements
have been executed, the test condition is
checked again. If it is still true the statements
get executed again. This cycle repeats until the
test condition evaluates to false.
11/14/2017 VIGNAN'S UNIVERSITY 13
Syntax
while ( expression )
{
Single statement
or
Block of statements;
}
11/14/2017 VIGNAN'S UNIVERSITY 14
Flowchart of while loop
11/14/2017 VIGNAN'S UNIVERSITY 15
do...while loop
• do ... while is just like a while loop except that
the test condition is checked at the end of the
loop rather than the start. This has the effect
that the content of the loop are always
executed at least once.
11/14/2017 VIGNAN'S UNIVERSITY 16
Syntax
Do
{
Single statement
or
Block of statements;
}while(expression);
11/14/2017 VIGNAN'S UNIVERSITY 17
Flow Chart
11/14/2017 VIGNAN'S UNIVERSITY 18
for loop
• for loop is similar to while, it's just written
differently.for statements are often used to
proccess lists such a range of numbers:
• In the syntax:
expression1 - Initialisese variables.
expression2 - Condtional expression, as long as this
condition is true, loop will keep executing.
expression3 - expression3 is the modifier which may
be simple increment of a variable.
11/14/2017 VIGNAN'S UNIVERSITY 19
Syntax
for( expression1; expression2; expression3)
{
Single statement
or
Block of statements;
}
11/14/2017 VIGNAN'S UNIVERSITY 20
Exercises
Refer word doc
11/14/2017 VIGNAN'S UNIVERSITY 21
Thank you
11/14/2017 VIGNAN'S UNIVERSITY 22

More Related Content

What's hot

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statementspragya ratan
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.netilakkiya
 
Conditional statements
Conditional statementsConditional statements
Conditional statementscherrybear2014
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsIt Academy
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loopFarshidKhan
 
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 statementRaj Parekh
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in JavaRavi_Kant_Sahu
 
Selection statements
Selection statementsSelection statements
Selection statementsHarsh Dabas
 
Control satkcher ppt
Control satkcher pptControl satkcher ppt
Control satkcher ppt6336Zeelvora
 
Java loops for, while and do...while
Java loops   for, while and do...whileJava loops   for, while and do...while
Java loops for, while and do...whileJayfee Ramos
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)Jyoti Bhardwaj
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statementsjyoti_lakhani
 

What's hot (20)

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 
Data structures vb
Data structures vbData structures vb
Data structures vb
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Chapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java StatementsChapter 2 : Programming with Java Statements
Chapter 2 : Programming with Java Statements
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
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
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 
Selection statements
Selection statementsSelection statements
Selection statements
 
Control satkcher ppt
Control satkcher pptControl satkcher ppt
Control satkcher ppt
 
Java loops for, while and do...while
Java loops   for, while and do...whileJava loops   for, while and do...while
Java loops for, while and do...while
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statements
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Chapter 4 java
Chapter 4 javaChapter 4 java
Chapter 4 java
 
If-else and switch-case
If-else and switch-caseIf-else and switch-case
If-else and switch-case
 

Similar to Control statements

Decision making and looping - c programming by YEASIN NEWAJ
Decision making and looping -  c programming by YEASIN NEWAJDecision making and looping -  c programming by YEASIN NEWAJ
Decision making and looping - c programming by YEASIN NEWAJYeasinNewaj
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptxAbhiYadav655132
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsEng Teong Cheah
 
Control statements
Control statementsControl statements
Control statementsCutyChhaya
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...jaychoudhary37
 
Ch # 11 2nd year computer science notes1
Ch # 11 2nd year computer science notes1Ch # 11 2nd year computer science notes1
Ch # 11 2nd year computer science notes1muhammadFaheem656405
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
Decision Making and Branching in C
Decision Making and Branching  in CDecision Making and Branching  in C
Decision Making and Branching in CRAJ KUMAR
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual BasicTushar Jain
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++guestfb6ada
 

Similar to Control statements (20)

Decision making and looping - c programming by YEASIN NEWAJ
Decision making and looping -  c programming by YEASIN NEWAJDecision making and looping -  c programming by YEASIN NEWAJ
Decision making and looping - c programming by YEASIN NEWAJ
 
UNIT 2 PPT.pdf
UNIT 2 PPT.pdfUNIT 2 PPT.pdf
UNIT 2 PPT.pdf
 
Control structures in c
Control structures in cControl structures in c
Control structures in c
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Fundamentals of Programming Chapter 6
Fundamentals of Programming Chapter 6Fundamentals of Programming Chapter 6
Fundamentals of Programming Chapter 6
 
Control statements
Control statementsControl statements
Control statements
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
 
Ch # 11 2nd year computer science notes1
Ch # 11 2nd year computer science notes1Ch # 11 2nd year computer science notes1
Ch # 11 2nd year computer science notes1
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
DECISION MAKING.pptx
DECISION MAKING.pptxDECISION MAKING.pptx
DECISION MAKING.pptx
 
Decision Making and Branching in C
Decision Making and Branching  in CDecision Making and Branching  in C
Decision Making and Branching in C
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
Flow control in c++
Flow control in c++Flow control in c++
Flow control in c++
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++
 

More from NAGUR SHAREEF SHAIK (10)

Perceptron & Neural Networks
Perceptron & Neural NetworksPerceptron & Neural Networks
Perceptron & Neural Networks
 
Theories on moral autonomy
Theories on moral autonomyTheories on moral autonomy
Theories on moral autonomy
 
Internet of things(IoT)
Internet of things(IoT)Internet of things(IoT)
Internet of things(IoT)
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Quantum Computers
Quantum ComputersQuantum Computers
Quantum Computers
 
Biodiversity and its conservation
Biodiversity and its  conservationBiodiversity and its  conservation
Biodiversity and its conservation
 
PHOTONIC CRYSTALS
PHOTONIC CRYSTALSPHOTONIC CRYSTALS
PHOTONIC CRYSTALS
 
Gravitational waves
Gravitational wavesGravitational waves
Gravitational waves
 
WASTE WATER TREATMENT
WASTE WATER TREATMENTWASTE WATER TREATMENT
WASTE WATER TREATMENT
 
Quantum computers
Quantum computersQuantum computers
Quantum computers
 

Recently uploaded

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 

Recently uploaded (20)

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 

Control statements

  • 2. 1. If statement • This is the most simple form of the branching statements. • It takes an expression in parenthesis and an statement or block of statements expresses, if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped. NOTE: Expression will be assumed to be true if its evaluated values is non-zero. 11/14/2017 VIGNAN'S UNIVERSITY 2
  • 3. SYNTAX Syntax: if (expression) statement; or if (expression) { Block of statements; } 11/14/2017 VIGNAN'S UNIVERSITY 3
  • 4. 2.If Else Statement: • An if statement can be followed by an optional else statement, which executes when the Boolean expression is false. • Syntax if(boolean_expression) { statement(s); } Else { statement(s) } 11/14/2017 VIGNAN'S UNIVERSITY 4
  • 5. Flowchart of if...else statement 11/14/2017 VIGNAN'S UNIVERSITY 5
  • 6. 3. Nested IF....ELSE • The if...else statement executes two different codes depending upon whether the test expression is true or false. Sometimes, a choice has to be made from more than 2 possibilities. In Nested if .....else, the if and else part can contain one or more if else statements. 11/14/2017 VIGNAN'S UNIVERSITY 6
  • 8. 4. ELSE .... IF LADDER • If we are having different – different test conditions with different – different statements, then for these kind of programming we need else if leader. Else if the leader is not interdependent to any other statements or any other test conditions. 11/14/2017 VIGNAN'S UNIVERSITY 8
  • 9. Syntax:if(test condition) { } else if(condition) { } else if(condition) { } else { } This construct is known as the else if ladder 11/14/2017 VIGNAN'S UNIVERSITY 9
  • 10. ii. Switch Statement • The switch statement is often faster than nested if...else (not always). Also, the syntax of switch statement is cleaner and easy to understand. • When a case constant is found that matches the switch expression, control of the program passes to the block of code associated with that case. • The break statement is used to prevent the code running into the next case. 11/14/2017 VIGNAN'S UNIVERSITY 10
  • 12. II. Looping • Loops provide a way to repeat commands and control how many times they are repeated. C provides a number of looping way. 1. While loop 2. do...while loop 3. for loop 11/14/2017 VIGNAN'S UNIVERSITY 12
  • 13. While loop • The most basic loop in C is the while loop.A while statement is like a repeating if statement. Like an If statement, if the test condition is true: the statments get executed. The difference is that after the statements have been executed, the test condition is checked again. If it is still true the statements get executed again. This cycle repeats until the test condition evaluates to false. 11/14/2017 VIGNAN'S UNIVERSITY 13
  • 14. Syntax while ( expression ) { Single statement or Block of statements; } 11/14/2017 VIGNAN'S UNIVERSITY 14
  • 15. Flowchart of while loop 11/14/2017 VIGNAN'S UNIVERSITY 15
  • 16. do...while loop • do ... while is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once. 11/14/2017 VIGNAN'S UNIVERSITY 16
  • 17. Syntax Do { Single statement or Block of statements; }while(expression); 11/14/2017 VIGNAN'S UNIVERSITY 17
  • 19. for loop • for loop is similar to while, it's just written differently.for statements are often used to proccess lists such a range of numbers: • In the syntax: expression1 - Initialisese variables. expression2 - Condtional expression, as long as this condition is true, loop will keep executing. expression3 - expression3 is the modifier which may be simple increment of a variable. 11/14/2017 VIGNAN'S UNIVERSITY 19
  • 20. Syntax for( expression1; expression2; expression3) { Single statement or Block of statements; } 11/14/2017 VIGNAN'S UNIVERSITY 20
  • 21. Exercises Refer word doc 11/14/2017 VIGNAN'S UNIVERSITY 21