SlideShare a Scribd company logo
STATEMENTS IN C
LANGUAGE
PRESENTRD BY:
Narra bhargavi
22AJ1A0562
CSE-A
C0NTENT
1
. I
N
T
R
O
D
U
C
T
I
O
N
2. IFC
O
N
D
I
T
IO
N
3. IFE
L
S
EC
O
N
D
IT
I
O
N
4
. N
E
S
T
E
DIFE
L
S
EC
O
N
D
IT
I
O
N
5
. L
A
D
D
E
RE
L
SEIFC
O
N
D
I
T
I
O
N
6
. S
W
I
T
C
HC
A
S
EC
O
N
D
IT
I
O
N
7
. B
R
E
A
KS
T
A
T
E
M
E
N
T
8
. G
O
T
OL
A
B
E
LS
T
A
T
E
M
E
N
T
9
. C
O
N
T
I
N
U
ES
T
A
T
E
M
E
N
T
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)
{
………………..
………………..
}
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.
Example #1: C if statement
// Program to display a number if user enters negative number
// If user enters positive number, that number won't be displayed
#include <stdio.h>
#include<conio.h>
void main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
// Test expression is true if number is less than 0
if (number < 0)
{
printf("You entered %d.n", number);
}
printf("The if statement is easy.");
getch();
}
IFE
L
S
EC
O
N
D
I
T
I
O
N
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.
SYNTAX:-
IF (CONDITION)
{
………………..
………………..
}
ELSE
{
………………..
………………..
}
=
EXAMPLE #2: C IF...ELSE STATEMENT
// PROGRAM TO CHECK WHETHER AN INTEGER ENTERED BY
THE USER IS ODD OR EVEN
#include <stdio.h>
#include<conio.h>
void main()
{
int number;
printf("Enter an integer: ");
scanf("%d",&number);
// True if remainder is 0
if( number%2 == 0 )
printf("%d is an even integer.",number);
else
printf("%d is an odd integer.",number);
getch();
}
NESTED IF ELSE
Using Of One If StatementWithin Another If Statement
Is Known As Nested Of If else Statement.
syntax-
if (……….)
{
………….
………….
if (………)
{
…………..
…………..
}
else
{
…………
…………
}
#Include <stdio.h>
#Include<conio.h>
Void main()
{
Int a,b;
Clrscr();
printf(“Enter Two
Numbers”);
scanf(“%d%d”,&a,&
b);
If(a==b)
{
else
If(a>b)
{
Printf(“a is greater”);
}
else
{
Printf(“b is greater”);
}
getch();
}
Q: - WAP to input two numbers and print the greatest
numbers.
L
A
D
D
E
RE
L
S
EIFC
O
N
D
ITIO
N
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.
2
Syntax: -
if (……….)
{
………….
…………. 1
}
else if (…….)
{
…………
…………
}
else if (………)
{
3
………….
………….
}
else
{
………….
…………. 4
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();
}
Q: - WAP to input three number and print the greatest
number.
S
W
I
T
C
HC
A
S
EC
O
N
D
I
T
I
O
N
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.
SWITCH CASE FLOW CHART
#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();
}
Q: - WAP to accept day no. (1 to 7) and print the day name
G
O
T
OL
A
B
E
L
C
O
N
D
IT
I
O
N
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;
----------
----------
---------
}
BHARGAVISTATEMENTS.PPT.pptx

More Related Content

Similar to BHARGAVISTATEMENTS.PPT.pptx

unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
ishaparte4
 
Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 
C Unit-2.ppt
C Unit-2.pptC Unit-2.ppt
C Unit-2.ppt
Giri383500
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
Komal Kotak
 
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
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
CHANDAN KUMAR
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
SmitaAparadh
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
Vikash Dhal
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Saranya saran
 
Simple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladderSimple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladder
Moni Adhikary
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
enidegmossu
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
NabishaAK
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
Mehul Desai
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
Suhail Akraam
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chapthuhiendtk4
 
Module 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdfModule 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdf
SudipDebnath20
 

Similar to BHARGAVISTATEMENTS.PPT.pptx (20)

unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
 
Branching statements
Branching statementsBranching statements
Branching statements
 
C Unit-2.ppt
C Unit-2.pptC Unit-2.ppt
C Unit-2.ppt
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
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
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Simple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladderSimple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladder
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Lec 10
Lec 10Lec 10
Lec 10
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chap
 
Module 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdfModule 2 - Control Structures c programming.pptm.pdf
Module 2 - Control Structures c programming.pptm.pdf
 

Recently uploaded

block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 

BHARGAVISTATEMENTS.PPT.pptx

  • 1. STATEMENTS IN C LANGUAGE PRESENTRD BY: Narra bhargavi 22AJ1A0562 CSE-A
  • 2. C0NTENT 1 . I N T R O D U C T I O N 2. IFC O N D I T IO N 3. IFE L S EC O N D IT I O N 4 . N E S T E DIFE L S EC O N D IT I O N 5 . L A D D E RE L SEIFC O N D I T I O N 6 . S W I T C HC A S EC O N D IT I O N 7 . B R E A KS T A T E M E N T 8 . G O T OL A B E LS T A T E M E N T 9 . C O N T I N U ES T A T E M E N T
  • 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) { ……………….. ……………….. } 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. Example #1: C if statement // Program to display a number if user enters negative number // If user enters positive number, that number won't be displayed #include <stdio.h> #include<conio.h> void main() { int number; printf("Enter an integer: "); scanf("%d", &number); // Test expression is true if number is less than 0 if (number < 0) { printf("You entered %d.n", number); } printf("The if statement is easy."); getch(); }
  • 7. IFE L S EC O N D I T I O N 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.
  • 9. EXAMPLE #2: C IF...ELSE STATEMENT // PROGRAM TO CHECK WHETHER AN INTEGER ENTERED BY THE USER IS ODD OR EVEN #include <stdio.h> #include<conio.h> void main() { int number; printf("Enter an integer: "); scanf("%d",&number); // True if remainder is 0 if( number%2 == 0 ) printf("%d is an even integer.",number); else printf("%d is an odd integer.",number); getch(); }
  • 10. NESTED IF ELSE Using Of One If StatementWithin Another If Statement Is Known As Nested Of If else Statement. syntax- if (……….) { …………. …………. if (………) { ………….. ………….. } else { ………… ………… }
  • 11. #Include <stdio.h> #Include<conio.h> Void main() { Int a,b; Clrscr(); printf(“Enter Two Numbers”); scanf(“%d%d”,&a,& b); If(a==b) { else If(a>b) { Printf(“a is greater”); } else { Printf(“b is greater”); } getch(); } Q: - WAP to input two numbers and print the greatest numbers.
  • 12. L A D D E RE L S EIFC O N D ITIO N 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.
  • 13. 2 Syntax: - if (……….) { …………. …………. 1 } else if (…….) { ………… ………… } else if (………) { 3 …………. …………. } else { …………. …………. 4
  • 14. 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(); } Q: - WAP to input three number and print the greatest number.
  • 15. S W I T C HC A S EC O N D I T I O N 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.
  • 16. 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.
  • 18. #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(); } Q: - WAP to accept day no. (1 to 7) and print the day name
  • 19. G O T OL A B E L C O N D IT I O N 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.
  • 20. 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.
  • 21. Syn: - goto label; Ex: - void main () { ram: ----- ------ ------- --------- goto ram; ---------- ---------- --------- }