SlideShare a Scribd company logo
1 of 12
NAME
SHUJA AHMAD
ROLL NO 1422
Control structure
• A statement used to control the flow of execution in a program
is called control structure.
• The control structure in are used to combine individual
instruction into a single logical unit.
• The logic unit has one entry point and one exit point.
Types of control structure
• Sequential structure
• Selection structure
• Repetition structure
• Function call
Sequential structure
• In sequential structure , the statement are executed in the same
order in which they are specified in program.
• The control flows from one statement to other in a
logical sequence.
• All statements are executed exactly once.
Selection structure
• A selection structure selects a statement or set of statement to
execute on the basic of a condition.
• In this structure ,statement or set of statement is execute when a
particular condition is true and ignored when the condition is
false
• There are different types of selection structure .These are if,if-else
and switch.
Repetition structure
• A repetition structure execute a statement or set of statements is
repeatedly
• It is also known as iteration structure or loop.
• The repetition structure include for loop,while loop and do-while
loop .
Function call
• Function call type of statement that moves the control to another
block of code.
• The control return back back after executing all statement in the
block.
• The remaining statements are executed immediately after the
function call when the control is returned .
Flow charts
Write a program that inputs two numbers from
user and display the result of first number raise
to the power of second number using do-while.
#include<stdio.h>
void main()
{
int a,b,c,r;
printf("Enter first number:");
scanf("%d",&a);
printf("Enter second number:");
scanf("%d",&b);
c=1;
r=1;
do
{
r=r*a;
c=c+1;
}
while(c<=b);
printf("Result is %d",r);
}
Write a program that produce following
output?
• 0 1
• 1 2
• 2 4
• 3 8
• 4 16
• 5 32
• 6 64
#include<stdio.h>
void main()
{
int I,j;
i=0; j=1;
while(i<=6)
{
Printf(“%d %dn”,I,j);
i=i+1; j=j+2;
}
}
Write a program that inputs a number from
the user and display the factorial of that
number using do-while loop?
#include<stdio.h>
void main()
{
Int n,c,f;
c=1;
f=1;
printf(Enter a number :”);
scanf(“%d”,&n);
do
{
f=f*c;
c=c+1;
}
While(c<=n);
Printf(“factorial of %d is %d”,n,f);
}

More Related Content

What's hot (19)

Functions and return type
Functions and return typeFunctions and return type
Functions and return type
 
CONTROL STRUCTURE
CONTROL STRUCTURECONTROL STRUCTURE
CONTROL STRUCTURE
 
Control structers in c
Control structers in cControl structers in c
Control structers in c
 
Chapter 7: Arithmetic and Relational Operators
Chapter 7:  Arithmetic and Relational Operators Chapter 7:  Arithmetic and Relational Operators
Chapter 7: Arithmetic and Relational Operators
 
St 1.6
St 1.6St 1.6
St 1.6
 
Fundamentals of-algorithm
Fundamentals of-algorithmFundamentals of-algorithm
Fundamentals of-algorithm
 
Unit 5. Control Statement
Unit 5. Control StatementUnit 5. Control Statement
Unit 5. Control Statement
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
K10655(hariom) control theory
K10655(hariom) control theoryK10655(hariom) control theory
K10655(hariom) control theory
 
Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilog
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9
 
user defined function
user defined functionuser defined function
user defined function
 
C- Language Lecture 2
C- Language Lecture 2C- Language Lecture 2
C- Language Lecture 2
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagrams
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamCritical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy Bijjam
 
Ch10
Ch10Ch10
Ch10
 

Viewers also liked

How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...
How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...
How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...CASRAI
 
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & Personal
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & PersonalF&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & Personal
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & PersonalCASRAI
 
공통 모듈을 이용한 화면 개발
공통 모듈을 이용한 화면 개발공통 모듈을 이용한 화면 개발
공통 모듈을 이용한 화면 개발jadunara
 
gracias chespirito
gracias chespiritogracias chespirito
gracias chespiritoCesar Vargas
 
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard Wynne
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard WynneCREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard Wynne
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard WynneCASRAI
 
Cuadro comparativo procedimiento por faltas
Cuadro comparativo procedimiento por faltasCuadro comparativo procedimiento por faltas
Cuadro comparativo procedimiento por faltasArianna Arrieche
 
Extincion de la obligacion tributaria uft
Extincion de la obligacion tributaria uftExtincion de la obligacion tributaria uft
Extincion de la obligacion tributaria uftLUIS HERNANDEZ
 
Environment of hrm
Environment of hrmEnvironment of hrm
Environment of hrmJETISH
 

Viewers also liked (15)

How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...
How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...
How Do I Know Thee? Let Me Count the Ways: Panel 2: Jeffrey Alexander & Patri...
 
resume
resumeresume
resume
 
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & Personal
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & PersonalF&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & Personal
F&I: Mike Conlon - Death by 1,000 Cuts: Researcher Burden Up Close & Personal
 
공통 모듈을 이용한 화면 개발
공통 모듈을 이용한 화면 개발공통 모듈을 이용한 화면 개발
공통 모듈을 이용한 화면 개발
 
gracias chespirito
gracias chespiritogracias chespirito
gracias chespirito
 
social profiler
social profilersocial profiler
social profiler
 
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard Wynne
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard WynneCREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard Wynne
CREDIT - Lightning Reports on 2015 CASRAI Standards Work - Richard Wynne
 
Cuadro comparativo procedimiento por faltas
Cuadro comparativo procedimiento por faltasCuadro comparativo procedimiento por faltas
Cuadro comparativo procedimiento por faltas
 
SMC 2 kwippy talk
SMC 2 kwippy talkSMC 2 kwippy talk
SMC 2 kwippy talk
 
WLAN AND IEEE STANDARDS
WLAN AND IEEE STANDARDSWLAN AND IEEE STANDARDS
WLAN AND IEEE STANDARDS
 
Extincion de la obligacion tributaria uft
Extincion de la obligacion tributaria uftExtincion de la obligacion tributaria uft
Extincion de la obligacion tributaria uft
 
Icd presentation
Icd presentationIcd presentation
Icd presentation
 
Raspberry pi 3
Raspberry pi 3Raspberry pi 3
Raspberry pi 3
 
Human Resource Management
Human Resource ManagementHuman Resource Management
Human Resource Management
 
Environment of hrm
Environment of hrmEnvironment of hrm
Environment of hrm
 

Similar to control structure by shuja ahmad

NRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptxNRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptxKRIPABHARDWAJ1
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonPriyankaC44
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in CSowmya Jyothi
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2sumitbardhan
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statementsVladislav Hadzhiyski
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques newJeet Thombare
 
Application engine
Application engineApplication engine
Application engineJAYAARC
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flowPushpa Yakkala
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural ProgrammingDeepam Aggarwal
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdfprakashvs7
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilizationJAYDEV PATEL
 
theory of programming languages by shikra
theory of programming languages by shikratheory of programming languages by shikra
theory of programming languages by shikrajateno3396
 

Similar to control structure by shuja ahmad (20)

NRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptxNRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptx
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
 
Slide 6_Control Structures.pdf
Slide 6_Control Structures.pdfSlide 6_Control Structures.pdf
Slide 6_Control Structures.pdf
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statements
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
 
Application engine
Application engineApplication engine
Application engine
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flow
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural Programming
 
Control structure in c
Control structure in cControl structure in c
Control structure in c
 
Programming-in-C
Programming-in-CProgramming-in-C
Programming-in-C
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdf
 
Software Testing
Software Testing Software Testing
Software Testing
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilization
 
C language (Part 2)
C language (Part 2)C language (Part 2)
C language (Part 2)
 
theory of programming languages by shikra
theory of programming languages by shikratheory of programming languages by shikra
theory of programming languages by shikra
 

More from Inocentshuja Ahmad (20)

Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
7th lec overview - latest
7th lec   overview - latest7th lec   overview - latest
7th lec overview - latest
 
6th lec infrared slides
6th lec   infrared slides6th lec   infrared slides
6th lec infrared slides
 
5th lec ofdm
5th lec   ofdm5th lec   ofdm
5th lec ofdm
 
3rd lec fcss
3rd lec   fcss3rd lec   fcss
3rd lec fcss
 
2nd lec wireless terminologies
2nd lec   wireless terminologies2nd lec   wireless terminologies
2nd lec wireless terminologies
 
1st lec generations
1st lec   generations1st lec   generations
1st lec generations
 
4rth lec dsss
4rth lec   dsss4rth lec   dsss
4rth lec dsss
 
Mcq's
Mcq'sMcq's
Mcq's
 
Long questions
Long questionsLong questions
Long questions
 
Lecture notes on mobile communication
Lecture notes on mobile communicationLecture notes on mobile communication
Lecture notes on mobile communication
 
Gsm
GsmGsm
Gsm
 
Lecture5 mobile communication_short
Lecture5 mobile communication_short Lecture5 mobile communication_short
Lecture5 mobile communication_short
 
8th lec flow and error control
8th lec   flow and error control8th lec   flow and error control
8th lec flow and error control
 
Chapter 10:Risk and Refinements In Capital Budgeting
Chapter 10:Risk and Refinements In Capital BudgetingChapter 10:Risk and Refinements In Capital Budgeting
Chapter 10:Risk and Refinements In Capital Budgeting
 
Chapter 9:Capital Budgeting Techniques
Chapter 9:Capital Budgeting TechniquesChapter 9:Capital Budgeting Techniques
Chapter 9:Capital Budgeting Techniques
 
Chapter 5:Risk and Return
Chapter 5:Risk and ReturnChapter 5:Risk and Return
Chapter 5:Risk and Return
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Email security &amp; threads
Email security &amp; threadsEmail security &amp; threads
Email security &amp; threads
 
Chapter03 Top Down Design with Function
Chapter03 Top Down Design with FunctionChapter03 Top Down Design with Function
Chapter03 Top Down Design with Function
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

control structure by shuja ahmad

  • 1.
  • 3. Control structure • A statement used to control the flow of execution in a program is called control structure. • The control structure in are used to combine individual instruction into a single logical unit. • The logic unit has one entry point and one exit point.
  • 4. Types of control structure • Sequential structure • Selection structure • Repetition structure • Function call
  • 5. Sequential structure • In sequential structure , the statement are executed in the same order in which they are specified in program. • The control flows from one statement to other in a logical sequence. • All statements are executed exactly once.
  • 6. Selection structure • A selection structure selects a statement or set of statement to execute on the basic of a condition. • In this structure ,statement or set of statement is execute when a particular condition is true and ignored when the condition is false • There are different types of selection structure .These are if,if-else and switch.
  • 7. Repetition structure • A repetition structure execute a statement or set of statements is repeatedly • It is also known as iteration structure or loop. • The repetition structure include for loop,while loop and do-while loop .
  • 8. Function call • Function call type of statement that moves the control to another block of code. • The control return back back after executing all statement in the block. • The remaining statements are executed immediately after the function call when the control is returned .
  • 10. Write a program that inputs two numbers from user and display the result of first number raise to the power of second number using do-while. #include<stdio.h> void main() { int a,b,c,r; printf("Enter first number:"); scanf("%d",&a); printf("Enter second number:"); scanf("%d",&b); c=1; r=1; do { r=r*a; c=c+1; } while(c<=b); printf("Result is %d",r); }
  • 11. Write a program that produce following output? • 0 1 • 1 2 • 2 4 • 3 8 • 4 16 • 5 32 • 6 64 #include<stdio.h> void main() { int I,j; i=0; j=1; while(i<=6) { Printf(“%d %dn”,I,j); i=i+1; j=j+2; } }
  • 12. Write a program that inputs a number from the user and display the factorial of that number using do-while loop? #include<stdio.h> void main() { Int n,c,f; c=1; f=1; printf(Enter a number :”); scanf(“%d”,&n); do { f=f*c; c=c+1; } While(c<=n); Printf(“factorial of %d is %d”,n,f); }