SlideShare a Scribd company logo
Control Flow Structure
• Control structures form the basic entities of a “structured
programming language“.
• Control structures are used to alter the flow of execution of the
program.
There are three types of control structures available in C and C++
• Sequence structure (straight line paths)
• Selection structure (one or many branches)
• Loop structure (repetition of a set of activities)
Sequence structure
Selection structure
If statement
if (condition)
{
Program statements;
}
If else statement
if (condition)
{
Program statements;
}
Else
{
Program statements;
}
Switch statement
switch (expression)
{
Case value_1;
Statement1;
Break;
Case value_2;
Statement2;
break;
Default:
Statementx;
break
}
Problem Statement
If the integer entered by user is 1 – output on screen “UNITED STATES”.
If the integer is 2 – output “SPAIN”, If the integer is 3 output “INDIA”. If
the user enters some other value – output “WRONG ENTRY”.
Loop structure (repetition of a set of activities)
• In programming, there exists situations when you need to repeat
single or a group of statements till some condition is met. Such as -
read all files of a directory, send mail to all employees one after
another etc. These task in C programming is handled by looping
statements.
• Looping statement defines a set of repetitive statements. These
statements are repeated with same or different parameters for a
number of times. Looping statement is also known
as iterative or repetitive statement.
C supports three looping statements.
• for loop
• while loop
• do...while loop
For Loop
• For loop is an entry controlled looping statement. It is used to repeat set of
statements until some condition is met.
• Looping statements whose condition is checked prior to the execution of
its body is called as Entry controlled loop.
Syntax of Loop
for(variable-initialization ; condition ; variable-update)
{
// Body of for loop
}
NRG 106_Session 4_CLanguage.pptx
/** * C program to print natural numbers from 1 to
10. */
#include <stdio.h>
int main()
{
/* Declare loop counter variable */
int count; /* Run a loop from 1 to 10 */
for(count=1; count<=10; count++)
{ /* Print current value of count */
printf("%d ", count);
}
return 0;
}
While Loop
Start
Initializing n=1
n < 10
Stop
Print n
n = n + 1
True
False
Do While Loop
Start
Initializing n=1
n < 10
Stop
Print n
n = n + 1
True
False

More Related Content

PPTX
Module 2- Control Structures
nikshaikh786
 
PPTX
C PROGRAMMING-CONTROL STATEMENT (IF-ELSE, SWITCH)
PallaviGholap4
 
PPT
170120107074 looping statements and nesting of loop statements
harsh kothari
 
PPSX
C lecture 3 control statements slideshare
Gagan Deep
 
PPTX
C Programming Control Structures(if,if-else)
poonambhagat36
 
PPTX
SwitchandlomahsjhASSJjajdjsdjdjjjop.pptx
AnanyaSingh813245
 
PPTX
computer programming and utilization
JAYDEV PATEL
 
PDF
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
MD RIZWAN MOLLA
 
Module 2- Control Structures
nikshaikh786
 
C PROGRAMMING-CONTROL STATEMENT (IF-ELSE, SWITCH)
PallaviGholap4
 
170120107074 looping statements and nesting of loop statements
harsh kothari
 
C lecture 3 control statements slideshare
Gagan Deep
 
C Programming Control Structures(if,if-else)
poonambhagat36
 
SwitchandlomahsjhASSJjajdjsdjdjjjop.pptx
AnanyaSingh813245
 
computer programming and utilization
JAYDEV PATEL
 
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
MD RIZWAN MOLLA
 

Similar to NRG 106_Session 4_CLanguage.pptx (20)

PPTX
control structure by shuja ahmad
Inocentshuja Ahmad
 
PPT
Control structure C++
Anil Kumar
 
DOCX
Programming Fundamentals lecture 8
REHAN IJAZ
 
PPTX
LESSON 6-Computer programming control structure 1
claritoBaluyot2
 
PDF
Repetition, Basic loop structures, Loop programming techniques
Jason J Pulikkottil
 
PDF
Bt0067 c programming and data structures 1
Techglyphs
 
PPTX
Cse lecture-7-c loop
FarshidKhan
 
PPTX
Session05 iteration structure
HarithaRanasinghe
 
PPTX
Claguage 110226222227-phpapp02
CIMAP
 
PPT
2. Control structures with for while and do while.ppt
ManojKhadilkar1
 
PDF
Loop and while Loop
JayBhavsar68
 
PPTX
Programming Fundamentals in C++ structures
ayshasafdarwaada
 
PPTX
Loop control structure
Karan Pandey
 
PPTX
C language 2
Arafat Bin Reza
 
PPT
Control structures repetition
Online
 
PPTX
Decision Making and Looping
Munazza-Mah-Jabeen
 
DOC
3. control statement
Shankar Gangaju
 
PPTX
9. control statement
Zambales National High School
 
control structure by shuja ahmad
Inocentshuja Ahmad
 
Control structure C++
Anil Kumar
 
Programming Fundamentals lecture 8
REHAN IJAZ
 
LESSON 6-Computer programming control structure 1
claritoBaluyot2
 
Repetition, Basic loop structures, Loop programming techniques
Jason J Pulikkottil
 
Bt0067 c programming and data structures 1
Techglyphs
 
Cse lecture-7-c loop
FarshidKhan
 
Session05 iteration structure
HarithaRanasinghe
 
Claguage 110226222227-phpapp02
CIMAP
 
2. Control structures with for while and do while.ppt
ManojKhadilkar1
 
Loop and while Loop
JayBhavsar68
 
Programming Fundamentals in C++ structures
ayshasafdarwaada
 
Loop control structure
Karan Pandey
 
C language 2
Arafat Bin Reza
 
Control structures repetition
Online
 
Decision Making and Looping
Munazza-Mah-Jabeen
 
3. control statement
Shankar Gangaju
 
9. control statement
Zambales National High School
 
Ad

More from KRIPABHARDWAJ1 (10)

PPTX
gis assgnmnt.pptx
KRIPABHARDWAJ1
 
PPTX
NRG 106_Session 6_String&Pointer.pptx
KRIPABHARDWAJ1
 
PPTX
NRG 106_Session 2_FlowCharts.pptx
KRIPABHARDWAJ1
 
PPTX
NRG 106_Session 1_History.pptx
KRIPABHARDWAJ1
 
PPTX
Dams- Politics of Displacement (Domestic) (1).pptx
KRIPABHARDWAJ1
 
PPTX
Rain Water Harvesting.pptx
KRIPABHARDWAJ1
 
PPTX
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
KRIPABHARDWAJ1
 
PPTX
SOURCES OF POPULATION DATA.pptx
KRIPABHARDWAJ1
 
PPTX
French & Industrial Rev..pptx
KRIPABHARDWAJ1
 
PPTX
Landslide.pptx
KRIPABHARDWAJ1
 
gis assgnmnt.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 6_String&Pointer.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 2_FlowCharts.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 1_History.pptx
KRIPABHARDWAJ1
 
Dams- Politics of Displacement (Domestic) (1).pptx
KRIPABHARDWAJ1
 
Rain Water Harvesting.pptx
KRIPABHARDWAJ1
 
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
KRIPABHARDWAJ1
 
SOURCES OF POPULATION DATA.pptx
KRIPABHARDWAJ1
 
French & Industrial Rev..pptx
KRIPABHARDWAJ1
 
Landslide.pptx
KRIPABHARDWAJ1
 
Ad

Recently uploaded (20)

PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Software Development Company | KodekX
KodekX
 
PPTX
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Beyond Automation: The Role of IoT Sensor Integration in Next-Gen Industries
Rejig Digital
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Software Development Company | KodekX
KodekX
 
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Beyond Automation: The Role of IoT Sensor Integration in Next-Gen Industries
Rejig Digital
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Software Development Methodologies in 2025
KodekX
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 

NRG 106_Session 4_CLanguage.pptx

  • 2. • Control structures form the basic entities of a “structured programming language“. • Control structures are used to alter the flow of execution of the program.
  • 3. There are three types of control structures available in C and C++ • Sequence structure (straight line paths) • Selection structure (one or many branches) • Loop structure (repetition of a set of activities)
  • 6. If statement if (condition) { Program statements; } If else statement if (condition) { Program statements; } Else { Program statements; } Switch statement switch (expression) { Case value_1; Statement1; Break; Case value_2; Statement2; break; Default: Statementx; break }
  • 7. Problem Statement If the integer entered by user is 1 – output on screen “UNITED STATES”. If the integer is 2 – output “SPAIN”, If the integer is 3 output “INDIA”. If the user enters some other value – output “WRONG ENTRY”.
  • 8. Loop structure (repetition of a set of activities) • In programming, there exists situations when you need to repeat single or a group of statements till some condition is met. Such as - read all files of a directory, send mail to all employees one after another etc. These task in C programming is handled by looping statements. • Looping statement defines a set of repetitive statements. These statements are repeated with same or different parameters for a number of times. Looping statement is also known as iterative or repetitive statement.
  • 9. C supports three looping statements. • for loop • while loop • do...while loop
  • 10. For Loop • For loop is an entry controlled looping statement. It is used to repeat set of statements until some condition is met. • Looping statements whose condition is checked prior to the execution of its body is called as Entry controlled loop. Syntax of Loop for(variable-initialization ; condition ; variable-update) { // Body of for loop }
  • 12. /** * C program to print natural numbers from 1 to 10. */ #include <stdio.h> int main() { /* Declare loop counter variable */ int count; /* Run a loop from 1 to 10 */ for(count=1; count<=10; count++) { /* Print current value of count */ printf("%d ", count); } return 0; }
  • 13. While Loop Start Initializing n=1 n < 10 Stop Print n n = n + 1 True False
  • 14. Do While Loop Start Initializing n=1 n < 10 Stop Print n n = n + 1 True False