SlideShare uma empresa Scribd logo
1 de 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);
}

Mais conteúdo relacionado

Mais procurados

Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9
koolkampus
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagrams
APU
 

Mais procurados (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
 

Destaque

gracias chespirito
gracias chespiritogracias chespirito
gracias chespirito
Cesar Vargas
 

Destaque (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
 

Semelhante a control structure by shuja ahmad

Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
Vasavi College of Engg
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
SatyamMishra828076
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
Jeet Thombare
 
Application engine
Application engineApplication engine
Application engine
JAYAARC
 

Semelhante a 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
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).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)
 

Mais de Inocentshuja Ahmad

Mais de 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
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
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
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

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); }