SlideShare a Scribd company logo
LECTURE 6
PROGRAMMING IN C
LANGUAGE
VIDYA CLASES
Asstt. Professor
Department of computer science and IT
Decision making and
branching
 Many time we required to change the sequential order of
execution of statement based on certain condition .This
involves a kind of decision making to see whether a particular
condition has occurred or not and then direct the computer to
execute certain statement accordingly.
 Some decision making statements are as follows
1) If statement
2) Switch statement
3) Conditional operator statement
4) Goto statement
If statement
 It is a control statement that tests a particular
condition.whenever the evaluated condition comes out to be
true then that action or set of actions are carried out.
 Syntax if(expression) if(test expression)
{
statements statement block;
} statement –x;
Test exp? False
True
/*To print largest of two nos*/
#include<stdio.h>
Void main()
{
Int a=20;
Int b=40;
If (a>b)
{
Printf(“a is large=%d”,a);
}
getch();
}
IF-ELSE STATEMENT
If(test expression)
(
True statement block;
}
Else
{
False statement block;
}
/* Prog. For calculating largest of two nos*/
#include<stdio.h>
{
Int a,b;
Printf(“enter two nos”);
Scanf(“%d%d”,&a,&b);
If(a>b)
{
Printf(“first no is large=%d”,a);
}
Else
{
Printf(“second no is large=%d”,b);
}
getch();
}
NESTED IF…ELSE STATEMENT
• When a series of decision are involved. We required to use more than one if….else
statement in nested form as below
If(test cond1)
{
If (test cond2)
{
Statement 1;
}
Else
{
Statement 2;
}
}
Else
{
statement3;
} statement-x;
/*To find largest of three nos*/
#include<stdio.h>
#include<conio.h>
Void main()
{
Float a,b,c;
Printf(“enter the values”);
Scanf(“%f%f%f”,&a,&b,&c);
Printf(“largest vales”);
If(a>b)
{
If(a>c)
Printf(“%f”,a);
Else
Printf(“%f”,c);
}
Else
{
If(c>b)
Printf(“%f”,c);
Else
Printf(“%f”,b);
}
Getch();
IF-ELSE-IF LADDER
If(condition1)
Statement1;
Else if(condition2)
Statement2;
Else f(condition3)
Statement3;
……………….
Else
Statement;
/* prog to demonstrate if-else-if ladder*/
#include<stdio.h>
#include<conio.h>
Void main()
{
Char a;
Printf(“please enter an alphabetic character”);
Scanf(“%c”,&a);
If(a>64&&a<=91)
Printf(“character is an uppercase”);
Else if(a>96&&a<=123)
Printf(“The character is a lowercase”);
Else
Printf(“This is not an alphabetic character”);
getch();
}
Thank you

More Related Content

Similar to lecture 6 bca 1 year-1.pptx

Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-ExpressionsProgramming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-Expressions
LovelitJose
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
Mehul Desai
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Hossain Md Shakhawat
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
Praveen M Jigajinni
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
ManojKhadilkar1
 
Chapter 8 - Conditional Statement
Chapter 8 - Conditional StatementChapter 8 - Conditional Statement
Chapter 8 - Conditional Statement
Deepak Singh
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
Unit testing 101
Unit testing 101Unit testing 101
Unit testing 101
Erkin Ünlü
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
alish sha
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
teach4uin
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
Deepak Lakhlan
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
ilakkiya
 
control statements
control statementscontrol statements
control statements
Azeem Sultan
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 
Unit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment exampleUnit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment example
umaghosal12101974
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 

Similar to lecture 6 bca 1 year-1.pptx (20)

Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-ExpressionsProgramming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-Expressions
 
CH-4 (1).pptx
CH-4 (1).pptxCH-4 (1).pptx
CH-4 (1).pptx
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
Chapter 8 - Conditional Statement
Chapter 8 - Conditional StatementChapter 8 - Conditional Statement
Chapter 8 - Conditional Statement
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Unit testing 101
Unit testing 101Unit testing 101
Unit testing 101
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
 
control statements
control statementscontrol statements
control statements
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Unit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment exampleUnit_3A_If_Else_Switch and a if else statment example
Unit_3A_If_Else_Switch and a if else statment example
 
Control Structures
Control StructuresControl Structures
Control Structures
 

More from classall

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
classall
 
CONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VBCONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VB
classall
 
operat in vb .pptx
operat in vb .pptxoperat in vb .pptx
operat in vb .pptx
classall
 
Tally_Tutor_1.ppt
Tally_Tutor_1.pptTally_Tutor_1.ppt
Tally_Tutor_1.ppt
classall
 
networking
networking networking
networking
classall
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
classall
 
introduction to e-commerce.pptx
introduction to e-commerce.pptxintroduction to e-commerce.pptx
introduction to e-commerce.pptx
classall
 
E-Rdiagram.ppt
E-Rdiagram.pptE-Rdiagram.ppt
E-Rdiagram.ppt
classall
 
EDI presentation.pptx
EDI presentation.pptxEDI presentation.pptx
EDI presentation.pptx
classall
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
classall
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
classall
 
SAVE WATER SAVE LIFE
SAVE WATER SAVE LIFESAVE WATER SAVE LIFE
SAVE WATER SAVE LIFE
classall
 
MS OFFICE
MS OFFICEMS OFFICE
MS OFFICE
classall
 
MULTIMEDIA
MULTIMEDIAMULTIMEDIA
MULTIMEDIA
classall
 
GEETA2.pptx
GEETA2.pptxGEETA2.pptx
GEETA2.pptx
classall
 
GEETA1.pptx
GEETA1.pptxGEETA1.pptx
GEETA1.pptx
classall
 
GEETA.pptx
GEETA.pptxGEETA.pptx
GEETA.pptx
classall
 
राष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.pptराष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.ppt
classall
 
mmu.pptx
mmu.pptxmmu.pptx
mmu.pptx
classall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 

More from classall (20)

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
CONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VBCONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VB
 
operat in vb .pptx
operat in vb .pptxoperat in vb .pptx
operat in vb .pptx
 
Tally_Tutor_1.ppt
Tally_Tutor_1.pptTally_Tutor_1.ppt
Tally_Tutor_1.ppt
 
networking
networking networking
networking
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
 
introduction to e-commerce.pptx
introduction to e-commerce.pptxintroduction to e-commerce.pptx
introduction to e-commerce.pptx
 
E-Rdiagram.ppt
E-Rdiagram.pptE-Rdiagram.ppt
E-Rdiagram.ppt
 
EDI presentation.pptx
EDI presentation.pptxEDI presentation.pptx
EDI presentation.pptx
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 
SAVE WATER SAVE LIFE
SAVE WATER SAVE LIFESAVE WATER SAVE LIFE
SAVE WATER SAVE LIFE
 
MS OFFICE
MS OFFICEMS OFFICE
MS OFFICE
 
MULTIMEDIA
MULTIMEDIAMULTIMEDIA
MULTIMEDIA
 
GEETA2.pptx
GEETA2.pptxGEETA2.pptx
GEETA2.pptx
 
GEETA1.pptx
GEETA1.pptxGEETA1.pptx
GEETA1.pptx
 
GEETA.pptx
GEETA.pptxGEETA.pptx
GEETA.pptx
 
राष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.pptराष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.ppt
 
mmu.pptx
mmu.pptxmmu.pptx
mmu.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 

Recently uploaded

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 

Recently uploaded (20)

ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 

lecture 6 bca 1 year-1.pptx

  • 1. LECTURE 6 PROGRAMMING IN C LANGUAGE VIDYA CLASES Asstt. Professor Department of computer science and IT
  • 2. Decision making and branching  Many time we required to change the sequential order of execution of statement based on certain condition .This involves a kind of decision making to see whether a particular condition has occurred or not and then direct the computer to execute certain statement accordingly.  Some decision making statements are as follows 1) If statement 2) Switch statement 3) Conditional operator statement 4) Goto statement
  • 3. If statement  It is a control statement that tests a particular condition.whenever the evaluated condition comes out to be true then that action or set of actions are carried out.  Syntax if(expression) if(test expression) { statements statement block; } statement –x; Test exp? False True
  • 4. /*To print largest of two nos*/ #include<stdio.h> Void main() { Int a=20; Int b=40; If (a>b) { Printf(“a is large=%d”,a); } getch(); }
  • 5. IF-ELSE STATEMENT If(test expression) ( True statement block; } Else { False statement block; }
  • 6. /* Prog. For calculating largest of two nos*/ #include<stdio.h> { Int a,b; Printf(“enter two nos”); Scanf(“%d%d”,&a,&b); If(a>b) { Printf(“first no is large=%d”,a); } Else { Printf(“second no is large=%d”,b); } getch(); }
  • 7. NESTED IF…ELSE STATEMENT • When a series of decision are involved. We required to use more than one if….else statement in nested form as below If(test cond1) { If (test cond2) { Statement 1; } Else { Statement 2; } } Else { statement3; } statement-x;
  • 8. /*To find largest of three nos*/ #include<stdio.h> #include<conio.h> Void main() { Float a,b,c; Printf(“enter the values”); Scanf(“%f%f%f”,&a,&b,&c); Printf(“largest vales”); If(a>b) { If(a>c) Printf(“%f”,a); Else Printf(“%f”,c); } Else { If(c>b) Printf(“%f”,c); Else Printf(“%f”,b); } Getch();
  • 9. IF-ELSE-IF LADDER If(condition1) Statement1; Else if(condition2) Statement2; Else f(condition3) Statement3; ………………. Else Statement;
  • 10. /* prog to demonstrate if-else-if ladder*/ #include<stdio.h> #include<conio.h> Void main() { Char a; Printf(“please enter an alphabetic character”); Scanf(“%c”,&a); If(a>64&&a<=91) Printf(“character is an uppercase”); Else if(a>96&&a<=123) Printf(“The character is a lowercase”); Else Printf(“This is not an alphabetic character”); getch(); }