SlideShare uma empresa Scribd logo
1 de 19
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

Mais conteúdo relacionado

Mais procurados

Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++Nilesh Dalvi
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Neeru Mittal
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 
Conditional statement in c
Conditional statement in cConditional statement in c
Conditional statement in cMuthuganesh S
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements Tarun Sharma
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programmingCHANDAN KUMAR
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CBUBT
 

Mais procurados (20)

Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Conditional statement in c
Conditional statement in cConditional statement in c
Conditional statement in c
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Strings
StringsStrings
Strings
 
Loops c++
Loops c++Loops c++
Loops c++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
The Loops
The LoopsThe Loops
The Loops
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
C functions
C functionsC functions
C functions
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 

Semelhante a 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).pdfmounikanarra3
 
BHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptxBHARGAVISTATEMENTS.PPT.pptx
BHARGAVISTATEMENTS.PPT.pptxSasideepa
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptSanjjaayyy
 
Branching statements
Branching statementsBranching statements
Branching statementsArunMK17
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptxishaparte4
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin cVikash Dhal
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programmingnmahi96
 
Conditional statements
Conditional statementsConditional statements
Conditional statementsNabishaAK
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptxeaglesniper008
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
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.pptxSmitaAparadh
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
Control structure of c
Control structure of cControl structure of c
Control structure of cKomal Kotak
 
LET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSLET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSKavyaSharma65
 

Semelhante a 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
 
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
 
LET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSLET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERS
 

Último

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Último (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

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; ---------- ---------- --------- }