SlideShare a Scribd company logo
Computer Programming:
C language
Subject Teacher:
Abdul Rehman
Lecture – 17 & 18
The Decision Control Structure
• Decision making statements are used to skip or to execute a group of
statements based on the result of some condition.
• The decision making statements are,
− simple if statement
− if…else statement
− nested if
− else … if ladder
− switch statement
− goto
• These statements are also called branching statements
IF Statement
• if statement executes a single statement or a block of statements if a
boolean expression evaluates to true.
Syntax:
If(condition)
{
Statements;
}
Here condition is a boolean expression
If condition is true, then the statement is executed
If condition is false, than the statement is bypassed
Simple if statement
Syntax:
if(condition)
{
Statements;
}
if(condition)
Statements;
False
True (Bypass)
Simple if - Example
#include<stdio.h>
#include<conio.h>
int main()
{
int num1,num2;
printf("Enter any two numbers ");
scanf("%d %d",&num1,&num2);
if(num1>num2)
printf("nNum1 is greater than Num2");
printf("nEnd of program");
getch();
}
Output1
Enter any two numbers 10 5
Num1 is greater than Num2
End of program
Output1
Enter any two numbers 10 50
End of program
IF Else Statement
• An if statement can include an else clause that executes a statement or block
if the boolean expression is not true.
Syntax:
If (condition)
Statement1;
Else
Statement2;
• If condition is true, then statement1 is executed.
• Otherwise, statement2 is executed.
if - else statement
Syntax:
if(condition)
{
True block statements;
}
else
{
False block statements;
}
if(condi
tion)
True Block
Statement
False
True
False Block
Statements
if – else Example
# include <stdio.h>
void main ()
{
int num;
printf ("Type a number:");
scanf ("%d", &num);
if (number < 0)
printf(“The number is negative”);
else
printf(“The number is positive”);
}
Output
Type a number 50
The number is positive
if – else Example
#include<stdio.h>
void main()
{
Int num;
printf ("Enter a number:");
scanf ("%d",&num);
if (num%2==0)
printf ("The number is
EVEN.n");
else
printf ("The number is
ODD.n");
}
Output
Enter a number 125
The number is ODD
if – else Example
#include<stdio.h>
#include<conio.h>
void main (void)
{
int percentage;
printf(“Enter your percentage: “);
scanf(“%d”, &percentage);
if(percentage>=60)
printf(“You are Passed”);
else
printf(“You are failed”);
getch();
}
Else - if Ladder Statement
• An if statement can be followed by an optional else
if...else statement, which is very useful to test various
conditions using single if...else if statement.
When using if , else if , else statements there are few points to
keep in mind:
• An if can have zero or one else's and it must come after any
else if's.
• An if can have zero to many else if's and they must come
before the else.
• Once an else if succeeds, none of the remaining else if's or
else's will be tested.
Else - if Ladder Statement
Syntax
if (condition1)
statement block 1;
else if (condition2)
statement block 2;
else if (condition3)
statement block 3;
:
:
else if (condition)
statement block n;
else
default statement;
Else - if Ladder Statement
If(condition1)
Default Statements;
True
False
Statements1;
Else if(condition2)
True
Statements2;
False
Else if(condition3)
Statements3;
False
True
Else - if Ladder Example
#include<stdio.h>
#include<conio.h>
void main(void)
{
int num1,num2;
clrscr();
printf(“Enter integer numbers to check: ”);
scanf(“%d %d”,&num1,&num2);
if(num1>num2)
printf(“num1 is greater than num2”);
else if(num1<num2)
printf(“num1 is less than num2”);
else
printf(“both numbers are equal”);
getch();
}
Else - if Ladder Example
#include <stdio.h>
void main ()
{
float perc;
printf ("Enter Percentage:");
scanf ("%f", &perc);
if (perc <= 100 && perc >= 80)
printf ("n A-1 Grade");
else if (perc >= 70)
printf("n A Grade");
else if (perc >= 60)
printf ("n B Grade");
else
printf ("Fail");
}
Output
Enter Percentage: 75
A Grade
Else - if Ladder Example
#include<stdio.h>
#include<conio.h>
int main()
{
float num1, num2; char op;
printf("Enter two numbers");
scanf("%f %f",&num1,&num2);
printf("nEnter operator (+,-,*,/)");
op=getche();
if(op =='+')
printf("nResult=%f",num1+num2);
else if(op == '-')
printf("nResult=%f",num1-num2);
else if(op == '*')
printf("nResult=%f",num1*num2);
else if(op == '/')
printf("nResult=%f",num1/num2);
else
printf("Invalid Operator");
getch(); }
Ad

More Related Content

What's hot (20)

C statements
C statementsC statements
C statements
Ahsann111
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
baabtra.com - No. 1 supplier of quality freshers
 
M C6java5
M C6java5M C6java5
M C6java5
mbruggen
 
Decision control structures
Decision control structuresDecision control structures
Decision control structures
Rahul Bathri
 
Selection statements
Selection statementsSelection statements
Selection statements
Harsh Dabas
 
M C6java6
M C6java6M C6java6
M C6java6
mbruggen
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
Tech
 
Chap 5(decision making-branching)
Chap 5(decision making-branching)Chap 5(decision making-branching)
Chap 5(decision making-branching)
Bangabandhu Sheikh Mujibur Rahman Science and Technology University
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
baabtra.com - No. 1 supplier of quality freshers
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
Maneesha Caldera
 
Bsit1
Bsit1Bsit1
Bsit1
jigeno
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
FarshidKhan
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statements
jyoti_lakhani
 
Java Decision Control
Java Decision ControlJava Decision Control
Java Decision Control
Jayfee Ramos
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
Archana Gopinath
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
teach4uin
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
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
 
C statements
C statementsC statements
C statements
Ahsann111
 
Decision control structures
Decision control structuresDecision control structures
Decision control structures
Rahul Bathri
 
Selection statements
Selection statementsSelection statements
Selection statements
Harsh Dabas
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
Tech
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
Raj Parekh
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
Maneesha Caldera
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
FarshidKhan
 
java programming- control statements
 java programming- control statements java programming- control statements
java programming- control statements
jyoti_lakhani
 
Java Decision Control
Java Decision ControlJava Decision Control
Java Decision Control
Jayfee Ramos
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
Archana Gopinath
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
teach4uin
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
Jyoti Bhardwaj
 
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
 

Viewers also liked (17)

Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
SINGH PROJECTS
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
Vijayalaxmi Wakode
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
Uses of computers
Uses of computersUses of computers
Uses of computers
Nazmul Hetfield Batchu
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
Lecture 2 history_of_c
Lecture 2 history_of_cLecture 2 history_of_c
Lecture 2 history_of_c
eShikshak
 
C++ history session 00 history
C++ history session 00   historyC++ history session 00   history
C++ history session 00 history
Arun Prakash
 
Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"
Nazmul Hetfield Batchu
 
Computer History
Computer HistoryComputer History
Computer History
Crystal Cunningham
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
History Of Computer
History Of ComputerHistory Of Computer
History Of Computer
guest420b9d
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
Jatin Jindal
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
GENERATION OF COMPUTERS.
GENERATION OF COMPUTERS.GENERATION OF COMPUTERS.
GENERATION OF COMPUTERS.
Sowjanya Sampathkumar
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
SINGH PROJECTS
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
Lecture 2 history_of_c
Lecture 2 history_of_cLecture 2 history_of_c
Lecture 2 history_of_c
eShikshak
 
C++ history session 00 history
C++ history session 00   historyC++ history session 00   history
C++ history session 00 history
Arun Prakash
 
Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"
Nazmul Hetfield Batchu
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
History Of Computer
History Of ComputerHistory Of Computer
History Of Computer
guest420b9d
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
Jatin Jindal
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
Ad

Similar to programming c language. (20)

Control Statements -if else in C programming.pptx
Control Statements -if else in C programming.pptxControl Statements -if else in C programming.pptx
Control Statements -if else in C programming.pptx
ganeshmahato20
 
Decision Control Structure If & Else
Decision Control Structure If & ElseDecision Control Structure If & Else
Decision Control Structure If & Else
Abdullah Bhojani
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
Likhil181
 
Branching in C
Branching in CBranching in C
Branching in C
Prabhu Govind
 
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
 
control statement
control statement control statement
control statement
Kathmandu University
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
imtiazalijoono
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 
Control statement-Selective
Control statement-SelectiveControl statement-Selective
Control statement-Selective
Nurul Zakiah Zamri Tan
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
control_structures_c_language_regarding how to represent the loop in language...
control_structures_c_language_regarding how to represent the loop in language...control_structures_c_language_regarding how to represent the loop in language...
control_structures_c_language_regarding how to represent the loop in language...
ShirishaBuduputi
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
ishaparte4
 
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdfPROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
JNTUK KAKINADA
 
control-statements in C Language MH.pptx
control-statements in C Language MH.pptxcontrol-statements in C Language MH.pptx
control-statements in C Language MH.pptx
mehedi_hasan
 
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
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
SmitaAparadh
 
CSE 1102 - Lecture 2 - C Control Statements.pptx
CSE 1102 - Lecture 2 - C Control Statements.pptxCSE 1102 - Lecture 2 - C Control Statements.pptx
CSE 1102 - Lecture 2 - C Control Statements.pptx
Salim Shadman Ankur
 
CONTROL FLOW STRUCTURE IN JAVA LANG.pdf
CONTROL FLOW  STRUCTURE IN JAVA LANG.pdfCONTROL FLOW  STRUCTURE IN JAVA LANG.pdf
CONTROL FLOW STRUCTURE IN JAVA LANG.pdf
riazahamed37
 
L3 control
L3 controlL3 control
L3 control
mondalakash2012
 
Control Statements -if else in C programming.pptx
Control Statements -if else in C programming.pptxControl Statements -if else in C programming.pptx
Control Statements -if else in C programming.pptx
ganeshmahato20
 
Decision Control Structure If & Else
Decision Control Structure If & ElseDecision Control Structure If & Else
Decision Control Structure If & Else
Abdullah Bhojani
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
Likhil181
 
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
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
imtiazalijoono
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
control_structures_c_language_regarding how to represent the loop in language...
control_structures_c_language_regarding how to represent the loop in language...control_structures_c_language_regarding how to represent the loop in language...
control_structures_c_language_regarding how to represent the loop in language...
ShirishaBuduputi
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
ishaparte4
 
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdfPROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
JNTUK KAKINADA
 
control-statements in C Language MH.pptx
control-statements in C Language MH.pptxcontrol-statements in C Language MH.pptx
control-statements in C Language MH.pptx
mehedi_hasan
 
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
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
SmitaAparadh
 
CSE 1102 - Lecture 2 - C Control Statements.pptx
CSE 1102 - Lecture 2 - C Control Statements.pptxCSE 1102 - Lecture 2 - C Control Statements.pptx
CSE 1102 - Lecture 2 - C Control Statements.pptx
Salim Shadman Ankur
 
CONTROL FLOW STRUCTURE IN JAVA LANG.pdf
CONTROL FLOW  STRUCTURE IN JAVA LANG.pdfCONTROL FLOW  STRUCTURE IN JAVA LANG.pdf
CONTROL FLOW STRUCTURE IN JAVA LANG.pdf
riazahamed37
 
Ad

More from Abdul Rehman (8)

Introduction Relational Marketing
Introduction Relational Marketing Introduction Relational Marketing
Introduction Relational Marketing
Abdul Rehman
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
Abdul Rehman
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
Abdul Rehman
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQL
Abdul Rehman
 
computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thing
Abdul Rehman
 
Education system in Pakistan
Education system in PakistanEducation system in Pakistan
Education system in Pakistan
Abdul Rehman
 
How to write a letter
How to write a letterHow to write a letter
How to write a letter
Abdul Rehman
 
Writing good paragraphs ppt
Writing good paragraphs pptWriting good paragraphs ppt
Writing good paragraphs ppt
Abdul Rehman
 
Introduction Relational Marketing
Introduction Relational Marketing Introduction Relational Marketing
Introduction Relational Marketing
Abdul Rehman
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
Abdul Rehman
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
Abdul Rehman
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQL
Abdul Rehman
 
computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thing
Abdul Rehman
 
Education system in Pakistan
Education system in PakistanEducation system in Pakistan
Education system in Pakistan
Abdul Rehman
 
How to write a letter
How to write a letterHow to write a letter
How to write a letter
Abdul Rehman
 
Writing good paragraphs ppt
Writing good paragraphs pptWriting good paragraphs ppt
Writing good paragraphs ppt
Abdul Rehman
 

Recently uploaded (20)

Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 

programming c language.

  • 1. Computer Programming: C language Subject Teacher: Abdul Rehman Lecture – 17 & 18
  • 2. The Decision Control Structure • Decision making statements are used to skip or to execute a group of statements based on the result of some condition. • The decision making statements are, − simple if statement − if…else statement − nested if − else … if ladder − switch statement − goto • These statements are also called branching statements
  • 3. IF Statement • if statement executes a single statement or a block of statements if a boolean expression evaluates to true. Syntax: If(condition) { Statements; } Here condition is a boolean expression If condition is true, then the statement is executed If condition is false, than the statement is bypassed
  • 5. Simple if - Example #include<stdio.h> #include<conio.h> int main() { int num1,num2; printf("Enter any two numbers "); scanf("%d %d",&num1,&num2); if(num1>num2) printf("nNum1 is greater than Num2"); printf("nEnd of program"); getch(); } Output1 Enter any two numbers 10 5 Num1 is greater than Num2 End of program Output1 Enter any two numbers 10 50 End of program
  • 6. IF Else Statement • An if statement can include an else clause that executes a statement or block if the boolean expression is not true. Syntax: If (condition) Statement1; Else Statement2; • If condition is true, then statement1 is executed. • Otherwise, statement2 is executed.
  • 7. if - else statement Syntax: if(condition) { True block statements; } else { False block statements; } if(condi tion) True Block Statement False True False Block Statements
  • 8. if – else Example # include <stdio.h> void main () { int num; printf ("Type a number:"); scanf ("%d", &num); if (number < 0) printf(“The number is negative”); else printf(“The number is positive”); } Output Type a number 50 The number is positive
  • 9. if – else Example #include<stdio.h> void main() { Int num; printf ("Enter a number:"); scanf ("%d",&num); if (num%2==0) printf ("The number is EVEN.n"); else printf ("The number is ODD.n"); } Output Enter a number 125 The number is ODD
  • 10. if – else Example #include<stdio.h> #include<conio.h> void main (void) { int percentage; printf(“Enter your percentage: “); scanf(“%d”, &percentage); if(percentage>=60) printf(“You are Passed”); else printf(“You are failed”); getch(); }
  • 11. Else - if Ladder Statement • An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement. When using if , else if , else statements there are few points to keep in mind: • An if can have zero or one else's and it must come after any else if's. • An if can have zero to many else if's and they must come before the else. • Once an else if succeeds, none of the remaining else if's or else's will be tested.
  • 12. Else - if Ladder Statement Syntax if (condition1) statement block 1; else if (condition2) statement block 2; else if (condition3) statement block 3; : : else if (condition) statement block n; else default statement;
  • 13. Else - if Ladder Statement If(condition1) Default Statements; True False Statements1; Else if(condition2) True Statements2; False Else if(condition3) Statements3; False True
  • 14. Else - if Ladder Example #include<stdio.h> #include<conio.h> void main(void) { int num1,num2; clrscr(); printf(“Enter integer numbers to check: ”); scanf(“%d %d”,&num1,&num2); if(num1>num2) printf(“num1 is greater than num2”); else if(num1<num2) printf(“num1 is less than num2”); else printf(“both numbers are equal”); getch(); }
  • 15. Else - if Ladder Example #include <stdio.h> void main () { float perc; printf ("Enter Percentage:"); scanf ("%f", &perc); if (perc <= 100 && perc >= 80) printf ("n A-1 Grade"); else if (perc >= 70) printf("n A Grade"); else if (perc >= 60) printf ("n B Grade"); else printf ("Fail"); } Output Enter Percentage: 75 A Grade
  • 16. Else - if Ladder Example #include<stdio.h> #include<conio.h> int main() { float num1, num2; char op; printf("Enter two numbers"); scanf("%f %f",&num1,&num2); printf("nEnter operator (+,-,*,/)"); op=getche(); if(op =='+') printf("nResult=%f",num1+num2); else if(op == '-') printf("nResult=%f",num1-num2); else if(op == '*') printf("nResult=%f",num1*num2); else if(op == '/') printf("nResult=%f",num1/num2); else printf("Invalid Operator"); getch(); }
  翻译: