SlideShare a Scribd company logo
1 of 8
Download to read offline
Anil Sharma
sharma_anil@yahoo.com
CBIR Consulting
C programming talk at ITT tech
ITT-tech
 Control flow in software programs is required when program
execution should alter it’s behavior based on machine
conditions, user inputs, external triggers or internal triggers.
 It’s easier to program in human readable computer software
programming languages when program complexity dictates high
level spoken or written language like constructs. C is one such
high level language.
 C, as you already know, is a computer software programming
language that is more high-level (human readable) over low-
level (machine readable) i.e. low level machine language like
programming constructs are available at your disposal but high
level constructs are more in fashion.
 Control statements in execution flow control of a software
program are required when there is logical decision making
(conditional execution) involved during working of the machine
program based on its decision variables (conditions) of
execution.
Frequent “Conditional” branching or choice constructs
in C:
 “If-Then-Else” constructs
 Ternary check: “Statement? True : False” constructs
 “Switch – Case” statements?
 “Conditional - Looping” statements
 “If –then-else” conditional loop is used in those sections of the programs where branching
of logical flow of instructions is needed because of change in values of execution control
variables.
 Syntax:
if (condition) *“condition” check could involve one or more relational or boolean logical
tests.
if_true;
else // program could have multiple else statements qualified by another “if “
check i.e. “else if”
if_false;
In the example above, code branches out based on whether test condition is true or
false.
 Example Code:
int status;
pid_t pid = fork();
if (pid == -1) {
error("fatal fork error", true);
exit(FAILURE);
} else if (pid == 0) { // This is a child function.
child_function(args);
} else { // This is system call in parent context that puts the parent in
wait state for child.
(void)waitpid(pid, &status, 0);
}
exit(SUCCESS);
 Ternary operator (?:) is another conditional
expression available at programmers disposal for
choice tests:
Syntax:
(condition) ? (if_true) : (if_false)
If "condition" is true, the second expression is
executed ("if_true") otherwise the third expression
("if_false") is executed.
 Example code:
largest = ((a > b) ? a : b);
 “switch – case” statements controls the path of a program
execution based on the value of selection variable in multiple
choice decision scenarios.
 Syntax:
switch (variable) {
case ‘x’: statement; break;
.
.
case default: statement; break;
}
 Example code:
switch (age) {
case 1: printf("You're one."); break;
case 2: printf("You're two."); break;
case 3: printf("You're three."); break;
case 4: printf("You're four."); break;
default: printf("You're neither!"); break;
}
While(True) loop
 Execute a piece of code after test of truthfulness of a condition
based on the value of specified execution control variable.
 Syntax:
while ( condition ) {
/* code */
}
 Example Code:
int x = 0;
while ( x != 5 )
{
function_A();
x = x + 1;
}

More Related Content

What's hot

Muffler a tool using mutation to facilitate fault localization 2.0
Muffler a tool using mutation to facilitate fault localization 2.0Muffler a tool using mutation to facilitate fault localization 2.0
Muffler a tool using mutation to facilitate fault localization 2.0Tao He
 
Exception handling in c++ by manoj vasava
Exception handling in c++ by manoj vasavaException handling in c++ by manoj vasava
Exception handling in c++ by manoj vasavaManoj_vasava
 
6months industrial training in software testing, jalandhar
6months industrial training in software testing, jalandhar6months industrial training in software testing, jalandhar
6months industrial training in software testing, jalandhardeepikakaler1
 
6 weeks summer training in software testing,jalandhar
6 weeks summer training in software testing,jalandhar6 weeks summer training in software testing,jalandhar
6 weeks summer training in software testing,jalandhardeepikakaler1
 
EDD (Error Driven Development)
EDD (Error Driven Development)EDD (Error Driven Development)
EDD (Error Driven Development)Daniel Andrews
 

What's hot (10)

Muffler a tool using mutation to facilitate fault localization 2.0
Muffler a tool using mutation to facilitate fault localization 2.0Muffler a tool using mutation to facilitate fault localization 2.0
Muffler a tool using mutation to facilitate fault localization 2.0
 
Exception handling in c++ by manoj vasava
Exception handling in c++ by manoj vasavaException handling in c++ by manoj vasava
Exception handling in c++ by manoj vasava
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
Quiz5
Quiz5Quiz5
Quiz5
 
Testing
TestingTesting
Testing
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
H evaluation
H evaluationH evaluation
H evaluation
 
6months industrial training in software testing, jalandhar
6months industrial training in software testing, jalandhar6months industrial training in software testing, jalandhar
6months industrial training in software testing, jalandhar
 
6 weeks summer training in software testing,jalandhar
6 weeks summer training in software testing,jalandhar6 weeks summer training in software testing,jalandhar
6 weeks summer training in software testing,jalandhar
 
EDD (Error Driven Development)
EDD (Error Driven Development)EDD (Error Driven Development)
EDD (Error Driven Development)
 

Similar to C conditional mod

Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 
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_selectionalish 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_selectionalish sha
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programmingnmahi96
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docxJavvajiVenkat
 
Chap11 (ICS12).pdf
Chap11 (ICS12).pdfChap11 (ICS12).pdf
Chap11 (ICS12).pdfJounAbbas4
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 
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 ConceptsTech
 
Programming basics
Programming basicsProgramming basics
Programming basics246paa
 
Decision Making Statements, Arrays, Strings
Decision Making Statements, Arrays, StringsDecision Making Statements, Arrays, Strings
Decision Making Statements, Arrays, StringsPrabu U
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Shipra Swati
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlENGWAU TONNY
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statementCHANDAN KUMAR
 

Similar to C conditional mod (20)

Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 
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
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docx
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Oop lec 1
Oop lec 1Oop lec 1
Oop lec 1
 
Chap11 (ICS12).pdf
Chap11 (ICS12).pdfChap11 (ICS12).pdf
Chap11 (ICS12).pdf
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
Bsit1
Bsit1Bsit1
Bsit1
 
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
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Decision Making Statements, Arrays, Strings
Decision Making Statements, Arrays, StringsDecision Making Statements, Arrays, Strings
Decision Making Statements, Arrays, Strings
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
 

More from Anil Sharma

PUBLIC_DOMAIN_PERSONA.pdf
PUBLIC_DOMAIN_PERSONA.pdfPUBLIC_DOMAIN_PERSONA.pdf
PUBLIC_DOMAIN_PERSONA.pdfAnil Sharma
 
Changes in job_markets_for_indians
Changes in job_markets_for_indiansChanges in job_markets_for_indians
Changes in job_markets_for_indiansAnil Sharma
 
Work under progress_india_basic_econ
Work under progress_india_basic_econWork under progress_india_basic_econ
Work under progress_india_basic_econAnil Sharma
 
70 years of indian urbanization
70 years of indian urbanization70 years of indian urbanization
70 years of indian urbanizationAnil Sharma
 
Imp ms mba_projects_part1
Imp ms mba_projects_part1Imp ms mba_projects_part1
Imp ms mba_projects_part1Anil Sharma
 
Infrastructure development phase of indian economic development new
Infrastructure development phase of indian economic development newInfrastructure development phase of indian economic development new
Infrastructure development phase of indian economic development newAnil Sharma
 
Computing comm enhancements_in_modern_comm_nets
Computing comm enhancements_in_modern_comm_netsComputing comm enhancements_in_modern_comm_nets
Computing comm enhancements_in_modern_comm_netsAnil Sharma
 
1991 un india_econ_reform
1991 un india_econ_reform1991 un india_econ_reform
1991 un india_econ_reformAnil Sharma
 
India 20_metros_now_test
India  20_metros_now_testIndia  20_metros_now_test
India 20_metros_now_testAnil Sharma
 
Personality attrib software_arch
Personality attrib software_archPersonality attrib software_arch
Personality attrib software_archAnil Sharma
 
Focus on development_of_following_job_search
Focus on development_of_following_job_searchFocus on development_of_following_job_search
Focus on development_of_following_job_searchAnil Sharma
 
Focus on development_of_following_job_search
Focus on development_of_following_job_searchFocus on development_of_following_job_search
Focus on development_of_following_job_searchAnil Sharma
 
Digital transformation technologies
Digital transformation technologiesDigital transformation technologies
Digital transformation technologiesAnil Sharma
 
Good software architecture for business
Good software architecture for business Good software architecture for business
Good software architecture for business Anil Sharma
 
Consulting proposal labs
Consulting proposal labsConsulting proposal labs
Consulting proposal labsAnil Sharma
 
Alarming population trends
Alarming population trendsAlarming population trends
Alarming population trendsAnil Sharma
 
Little bit on_h1_processing_etc
Little bit on_h1_processing_etcLittle bit on_h1_processing_etc
Little bit on_h1_processing_etcAnil Sharma
 
Cbir consulting pp old
Cbir consulting pp oldCbir consulting pp old
Cbir consulting pp oldAnil Sharma
 

More from Anil Sharma (20)

PUBLIC_DOMAIN_PERSONA.pdf
PUBLIC_DOMAIN_PERSONA.pdfPUBLIC_DOMAIN_PERSONA.pdf
PUBLIC_DOMAIN_PERSONA.pdf
 
Changes in job_markets_for_indians
Changes in job_markets_for_indiansChanges in job_markets_for_indians
Changes in job_markets_for_indians
 
Work under progress_india_basic_econ
Work under progress_india_basic_econWork under progress_india_basic_econ
Work under progress_india_basic_econ
 
70 years of indian urbanization
70 years of indian urbanization70 years of indian urbanization
70 years of indian urbanization
 
Imp ms mba_projects_part1
Imp ms mba_projects_part1Imp ms mba_projects_part1
Imp ms mba_projects_part1
 
First corp proj
First corp projFirst corp proj
First corp proj
 
Infrastructure development phase of indian economic development new
Infrastructure development phase of indian economic development newInfrastructure development phase of indian economic development new
Infrastructure development phase of indian economic development new
 
Computing comm enhancements_in_modern_comm_nets
Computing comm enhancements_in_modern_comm_netsComputing comm enhancements_in_modern_comm_nets
Computing comm enhancements_in_modern_comm_nets
 
1991 un india_econ_reform
1991 un india_econ_reform1991 un india_econ_reform
1991 un india_econ_reform
 
India 20_metros_now_test
India  20_metros_now_testIndia  20_metros_now_test
India 20_metros_now_test
 
Personality attrib software_arch
Personality attrib software_archPersonality attrib software_arch
Personality attrib software_arch
 
Focus on development_of_following_job_search
Focus on development_of_following_job_searchFocus on development_of_following_job_search
Focus on development_of_following_job_search
 
Focus on development_of_following_job_search
Focus on development_of_following_job_searchFocus on development_of_following_job_search
Focus on development_of_following_job_search
 
Digital transformation technologies
Digital transformation technologiesDigital transformation technologies
Digital transformation technologies
 
Good software architecture for business
Good software architecture for business Good software architecture for business
Good software architecture for business
 
Cbir
CbirCbir
Cbir
 
Consulting proposal labs
Consulting proposal labsConsulting proposal labs
Consulting proposal labs
 
Alarming population trends
Alarming population trendsAlarming population trends
Alarming population trends
 
Little bit on_h1_processing_etc
Little bit on_h1_processing_etcLittle bit on_h1_processing_etc
Little bit on_h1_processing_etc
 
Cbir consulting pp old
Cbir consulting pp oldCbir consulting pp old
Cbir consulting pp old
 

Recently uploaded

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Recently uploaded (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

C conditional mod

  • 3.  Control flow in software programs is required when program execution should alter it’s behavior based on machine conditions, user inputs, external triggers or internal triggers.  It’s easier to program in human readable computer software programming languages when program complexity dictates high level spoken or written language like constructs. C is one such high level language.  C, as you already know, is a computer software programming language that is more high-level (human readable) over low- level (machine readable) i.e. low level machine language like programming constructs are available at your disposal but high level constructs are more in fashion.  Control statements in execution flow control of a software program are required when there is logical decision making (conditional execution) involved during working of the machine program based on its decision variables (conditions) of execution.
  • 4. Frequent “Conditional” branching or choice constructs in C:  “If-Then-Else” constructs  Ternary check: “Statement? True : False” constructs  “Switch – Case” statements?  “Conditional - Looping” statements
  • 5.  “If –then-else” conditional loop is used in those sections of the programs where branching of logical flow of instructions is needed because of change in values of execution control variables.  Syntax: if (condition) *“condition” check could involve one or more relational or boolean logical tests. if_true; else // program could have multiple else statements qualified by another “if “ check i.e. “else if” if_false; In the example above, code branches out based on whether test condition is true or false.  Example Code: int status; pid_t pid = fork(); if (pid == -1) { error("fatal fork error", true); exit(FAILURE); } else if (pid == 0) { // This is a child function. child_function(args); } else { // This is system call in parent context that puts the parent in wait state for child. (void)waitpid(pid, &status, 0); } exit(SUCCESS);
  • 6.  Ternary operator (?:) is another conditional expression available at programmers disposal for choice tests: Syntax: (condition) ? (if_true) : (if_false) If "condition" is true, the second expression is executed ("if_true") otherwise the third expression ("if_false") is executed.  Example code: largest = ((a > b) ? a : b);
  • 7.  “switch – case” statements controls the path of a program execution based on the value of selection variable in multiple choice decision scenarios.  Syntax: switch (variable) { case ‘x’: statement; break; . . case default: statement; break; }  Example code: switch (age) { case 1: printf("You're one."); break; case 2: printf("You're two."); break; case 3: printf("You're three."); break; case 4: printf("You're four."); break; default: printf("You're neither!"); break; }
  • 8. While(True) loop  Execute a piece of code after test of truthfulness of a condition based on the value of specified execution control variable.  Syntax: while ( condition ) { /* code */ }  Example Code: int x = 0; while ( x != 5 ) { function_A(); x = x + 1; }