SlideShare a Scribd company logo
1 of 22
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

Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chap
thuhiendtk4
 

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
 
3. control statement
3. control statement3. control statement
3. control statement
 

Recently uploaded

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
meharikiros2
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptx
hublikarsn
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 

Recently uploaded (20)

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
 
Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 

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