SlideShare a Scribd company logo
A 
PRESENTATION ON 
CONDITIONAL 
STATEMENT IN “C” 
LANGUAGE
C0NTENT 
1. INTRODUCTION 
2. IF CONDITION 
3. IF ELSE CONDITION 
4. NESTED IF ELSE CONDITION 
5. LADDER ELSE IF CONDITION 
6. SWITCH CASE CONDITION 
7. BREAK STATEMENT 
8. GOTO LABEL STATEMENT 
9. CONTINUE STATEMENT
INTRODUCTION 
Conditional Statements Are Used To Execute A 
Set Of Statements On Some Conditions. It 
Provides A Unit Of Block In Which We Can 
Either One Statement Or More Than One 
Statments. If The Given Condition Is True Then 
The Set Of Statements Are Executed Otherwise 
Body Is Skipped.
IF CONDITION 
It is conditional statement, which is used to 
execute a set of statement on some conditions. 
The condition must be of Boolean type 
expression. 
An expression, which returns only two value 
either TRUE or FALSE, is known as Boolean 
type expression.
Syntax: - if (condition) 
{ 
……………….. 
……………….. 
} 
Include <stdio.h> 
Include<conio.h> 
Void main() 
{ 
Int age; 
Clrscr(); 
If(age>18) 
{ 
Printf(he is eligiable for voting); 
} 
getch(); 
} 
In Another Words, It Can Also Be Said As Single 
Blocked Conditional Statements In Which Only One 
Part Is Mentioned. That Is Known As TRUE Part.
IF ELSE CONDITION 
It Is Known As Double Blocked Conditional 
Statements .It Means, It Has TRUE Parts As 
Well As FALSE Part. 
If The Given Condition Is True Then The 
True Part Is Executed Otherwise False Part Is 
Executed.
Q: -WAP to accept a number and cheak whether he is eligible for voting or not. 
Syntax: - 
if (condition) 
{ 
……………….. 
……………….. 
} 
else 
{ 
……………….. 
……………….. 
} 
Include <stdio.h> 
Include<conio.h> 
Void main() 
{ 
Int age; 
Clrscr(); 
If(age>18) 
{ 
Printf(he is eligiable for voting); 
} 
else 
{ 
Printf(he is not eligiable for 
voting); 
} 
getch(); 
}
NESTED IF ELSE 
Using Of One If Statement Within Another If Statement 
Is Known As Nested Of If else Statement. 
syntax-if 
(……….) 
} 
{ 
else 
…………. 
{ 
…………. 
………… 
if (………) 
………… 
{ 
} 
………….. 
…………..
Q: - WAP to input two numbers and print the gretest numbers. 
Include <stdio.h> 
Include<conio.h> 
Void main() 
{ 
Int a,b; 
Clrscr(); 
If(a==b) 
{ 
Printf(“a is equal to b”); 
} 
else 
If(a>b) 
{ 
Printf(“a is greater”); 
} 
else 
{ 
Printf(“b is greater”); 
} 
getch(); 
}
LADDER ELSE IF CONDITION 
When We Want To Specify Condition With Else 
Part Then We Have To Use Ladder Of If 
Statement. In This Case If The Condition 
Specified With First If -Statement Is False, Then 
Control Goes To Second ―Else If‖ Statement. If It 
Is True Then Part (2) Is Executed Otherwise 
Control Goes To Third ―Else-if‖ Statement. If It 
Is True, Then Part (3) Is Executed Otherwise Part 
(4) Is Executed. 
If The Condition Specified With First If Statement 
Is True, Then Part (1) Is Executed.
Syntax: - 
if (……….) 
{ 
…………. 
…………. 1 
} 
else if (…….) 
{ 
………… 
………… 2 
} 
else if (………) 
{ 
…………. 
…………. 3 
} 
else 
{ 
…………. 
…………. 4
Q: - WAP to input three number and print the greatest number. 
Include <stdio.h> 
Include<conio.h> 
Void main() 
{ 
Int a,b,c; 
Clrscr(); 
printf ("n enter first number: -"); 
scanf("%d",&a); 
printf("n enter secend number : -"); 
scanf("%d",&b); 
printf("n enter third number : -"); 
scanf("%d",&c); 
if(a>b) 
{ 
if(a>c) 
{ 
printf("n a is greatest: -"); 
} 
else 
{ 
printf("n c is greatest: -"); 
} 
} 
else 
if(b>c) 
{ 
printf("n b is greatest: -"); 
} 
else 
{ 
printf("n c is greatest: -"); 
} 
getch(); 
}
SWITCH CASE CONDITION 
It Is Multiple Conditioned Checking 
Statements, Which Is Generally Used For 
Menu- Driven Program Where We Have To 
Select One Option Out Of Several Options At 
A Time. 
The number of ―case within switch – 
statement is same as the number of options 
present in menu. Each ―case is used to do 
only one work at a time.
Default section: - 
It is optional section, which is generally used 
for error handling. It means by using this 
section we can displays error messages. In 
case of wrong choice entry or out of range 
choice. It is automatically executed when any 
user enters wrong choice.
Q: - WAP to accept day no. (1 to 7) and print the day name 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a; 
clrscr(); 
printf("enter day numbern****************"); 
scanf("%d",&a); 
switch(a) 
{ 
case 1: 
printf("monday"); 
break; 
case 2: 
printf("tuesday"); 
break; 
case 3: 
printf("wednesday"); 
break; 
case 4: 
printf("thirsday"); 
break; 
case 5: 
printf("friday"); 
break; 
case 6: 
printf("saturday"); 
break; 
case 7: 
printf("sunday"); 
break; 
default: 
printf("day not 
vailedn**************"); 
} 
getch(); 
}
GOTO LABELCONDITION 
This statement is used to send the control 
from one position to any desired position 
within a program. 
Since program is executed from top to bottom 
statement by statement. So if we want to 
execute certain part of program directly, then 
we can use this statement to do the same 
work.
Label: - 
May Be Any User Defined Name Or Identifiers. It Is 
Just Like A Variable But Not A Variable. It Should Not 
Be Declared As Variables By Any Data Type. 
Label Must Be Indicated At That Place Where We 
Want To Send The Control And It Must Be Followed 
By Colon (:) Sign. 
When It Is Directly Used In A Program Then It Just 
Works As Infinite Loop. So It Must Be Used On Some 
Condition.
Syn: - 
goto label; 
Ex: - 
void main () 
{ 
ram: 
----- 
------ 
------- 
--------- 
goto ram; 
---------- 
---------- 
--------- 
}
CONDITIONAL STATEMENT IN C LANGUAGE

More Related Content

What's hot

Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
Rabin BK
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
Ankita Totala
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
amber chaudary
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in JavaJin Castor
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
Venkata.Manish Reddy
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
If-else and switch-case
If-else and switch-caseIf-else and switch-case
If-else and switch-case
Manash Kumar Mondal
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Java Tokens
Java  TokensJava  Tokens
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
Dipesh Pandey
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 

What's hot (20)

Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Inline function
Inline functionInline function
Inline function
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
If-else and switch-case
If-else and switch-caseIf-else and switch-case
If-else and switch-case
 
Loops c++
Loops c++Loops c++
Loops c++
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 

Similar to CONDITIONAL STATEMENT IN C LANGUAGE

exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdf
mounikanarra3
 
BHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptxBHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptx
Sasideepa
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
ishaparte4
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
Vikash Dhal
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
nmahi96
 
C Unit-2.ppt
C Unit-2.pptC Unit-2.ppt
C Unit-2.ppt
Giri383500
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
Chandrakant Divate
 
Decision Making and Branching
Decision Making and BranchingDecision Making and Branching
Decision Making and Branching
Munazza-Mah-Jabeen
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
NabishaAK
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptx
eaglesniper008
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Saranya saran
 
3. control statement
3. control statement3. control statement
3. control statement
Shankar Gangaju
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
Loop's definition and practical code in C programming
Loop's definition and  practical code in C programming Loop's definition and  practical code in C programming
Loop's definition and practical code in C programming
DharmaKumariBhandari
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
SmitaAparadh
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
Komal Kotak
 

Similar to CONDITIONAL STATEMENT IN C LANGUAGE (20)

exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdf
 
BHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptxBHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptx
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
Branching statements
Branching statementsBranching statements
Branching statements
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
 
C Unit-2.ppt
C Unit-2.pptC Unit-2.ppt
C Unit-2.ppt
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
 
Decision Making and Branching
Decision Making and BranchingDecision Making and Branching
Decision Making and Branching
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptx
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
3. control statement
3. control statement3. control statement
3. control statement
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Loop's definition and practical code in C programming
Loop's definition and  practical code in C programming Loop's definition and  practical code in C programming
Loop's definition and practical code in C programming
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
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
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
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
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

CONDITIONAL STATEMENT IN C LANGUAGE

  • 1. A PRESENTATION ON CONDITIONAL STATEMENT IN “C” LANGUAGE
  • 2. C0NTENT 1. INTRODUCTION 2. IF CONDITION 3. IF ELSE CONDITION 4. NESTED IF ELSE CONDITION 5. LADDER ELSE IF CONDITION 6. SWITCH CASE CONDITION 7. BREAK STATEMENT 8. GOTO LABEL STATEMENT 9. CONTINUE STATEMENT
  • 3. INTRODUCTION Conditional Statements Are Used To Execute A Set Of Statements On Some Conditions. It Provides A Unit Of Block In Which We Can Either One Statement Or More Than One Statments. If The Given Condition Is True Then The Set Of Statements Are Executed Otherwise Body Is Skipped.
  • 4. IF CONDITION It is conditional statement, which is used to execute a set of statement on some conditions. The condition must be of Boolean type expression. An expression, which returns only two value either TRUE or FALSE, is known as Boolean type expression.
  • 5. Syntax: - if (condition) { ……………….. ……………….. } Include <stdio.h> Include<conio.h> Void main() { Int age; Clrscr(); If(age>18) { Printf(he is eligiable for voting); } getch(); } In Another Words, It Can Also Be Said As Single Blocked Conditional Statements In Which Only One Part Is Mentioned. That Is Known As TRUE Part.
  • 6. IF ELSE CONDITION It Is Known As Double Blocked Conditional Statements .It Means, It Has TRUE Parts As Well As FALSE Part. If The Given Condition Is True Then The True Part Is Executed Otherwise False Part Is Executed.
  • 7. Q: -WAP to accept a number and cheak whether he is eligible for voting or not. Syntax: - if (condition) { ……………….. ……………….. } else { ……………….. ……………….. } Include <stdio.h> Include<conio.h> Void main() { Int age; Clrscr(); If(age>18) { Printf(he is eligiable for voting); } else { Printf(he is not eligiable for voting); } getch(); }
  • 8. NESTED IF ELSE Using Of One If Statement Within Another If Statement Is Known As Nested Of If else Statement. syntax-if (……….) } { else …………. { …………. ………… if (………) ………… { } ………….. …………..
  • 9. Q: - WAP to input two numbers and print the gretest numbers. Include <stdio.h> Include<conio.h> Void main() { Int a,b; Clrscr(); If(a==b) { Printf(“a is equal to b”); } else If(a>b) { Printf(“a is greater”); } else { Printf(“b is greater”); } getch(); }
  • 10. LADDER ELSE IF CONDITION When We Want To Specify Condition With Else Part Then We Have To Use Ladder Of If Statement. In This Case If The Condition Specified With First If -Statement Is False, Then Control Goes To Second ―Else If‖ Statement. If It Is True Then Part (2) Is Executed Otherwise Control Goes To Third ―Else-if‖ Statement. If It Is True, Then Part (3) Is Executed Otherwise Part (4) Is Executed. If The Condition Specified With First If Statement Is True, Then Part (1) Is Executed.
  • 11. Syntax: - if (……….) { …………. …………. 1 } else if (…….) { ………… ………… 2 } else if (………) { …………. …………. 3 } else { …………. …………. 4
  • 12. Q: - WAP to input three number and print the greatest number. Include <stdio.h> Include<conio.h> Void main() { Int a,b,c; Clrscr(); printf ("n enter first number: -"); scanf("%d",&a); printf("n enter secend number : -"); scanf("%d",&b); printf("n enter third number : -"); scanf("%d",&c); if(a>b) { if(a>c) { printf("n a is greatest: -"); } else { printf("n c is greatest: -"); } } else if(b>c) { printf("n b is greatest: -"); } else { printf("n c is greatest: -"); } getch(); }
  • 13. SWITCH CASE CONDITION It Is Multiple Conditioned Checking Statements, Which Is Generally Used For Menu- Driven Program Where We Have To Select One Option Out Of Several Options At A Time. The number of ―case within switch – statement is same as the number of options present in menu. Each ―case is used to do only one work at a time.
  • 14. Default section: - It is optional section, which is generally used for error handling. It means by using this section we can displays error messages. In case of wrong choice entry or out of range choice. It is automatically executed when any user enters wrong choice.
  • 15. Q: - WAP to accept day no. (1 to 7) and print the day name #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("enter day numbern****************"); scanf("%d",&a); switch(a) { case 1: printf("monday"); break; case 2: printf("tuesday"); break; case 3: printf("wednesday"); break; case 4: printf("thirsday"); break; case 5: printf("friday"); break; case 6: printf("saturday"); break; case 7: printf("sunday"); break; default: printf("day not vailedn**************"); } getch(); }
  • 16. GOTO LABELCONDITION This statement is used to send the control from one position to any desired position within a program. Since program is executed from top to bottom statement by statement. So if we want to execute certain part of program directly, then we can use this statement to do the same work.
  • 17. Label: - May Be Any User Defined Name Or Identifiers. It Is Just Like A Variable But Not A Variable. It Should Not Be Declared As Variables By Any Data Type. Label Must Be Indicated At That Place Where We Want To Send The Control And It Must Be Followed By Colon (:) Sign. When It Is Directly Used In A Program Then It Just Works As Infinite Loop. So It Must Be Used On Some Condition.
  • 18. Syn: - goto label; Ex: - void main () { ram: ----- ------ ------- --------- goto ram; ---------- ---------- --------- }