SlideShare a Scribd company logo
Programming & Algorithm Loop Statements August 07, 2006
Array: The Basic An Array is an indexed group of data storage that have the same name and are distinguished from each other by an index (that is a number following the variable name, enclosed in brackets). A single-dimensional array declaration has the following form: typename array_name[size]; Note : The  first index  of an array is  zero .
Loop Statement The function is to execute one/some statement(s) several times. There are three loop statements: for statement while…do statement do…while statement
The  for S tatement Syntax: for ( initial ;  condition ;  increment ) statement(s);
The  for S tatement E.g.: Display the words  “Welcome to this cruel world..”  ten times. for (i ← 0; i ≤ 9; i ← i + 1) output(“Welcome to this cruel world..”)
Exercises Create an algorithm that displays numbers (1 to 25) on screen. Create an algorithm that uses loop statements to displays following formation of ‘*’ character on screen. a. b. c.
Exercises Create an algorithm that prints the result of X powered by Y. The algorithm received two numbers of integer (X and Y). Create an algorithm that asks one number of integer (N) and displays the numbers of Fibonacci on screen. E.g.: 1 1 2 3 5 8 13 7 Output Input
The  while S tatement Syntax: while ( condition ) statement(s);
The  do…while S tatement Syntax: do statement(s); while ( condition );
Nested Loops The term  nested loops  refers to a loop that is contained within another loop.
Exercises Create an algorithm that continually inputs one integer (N) and then displays a triangle (N rows). The algorithm will be terminated when the input is zero. E.g.: 4 Output Input
Exercises A mathematics' formula is shown by: Sn = (2 * n) + 3 Un = Sn + Sn- 1  + … + S 0 Create an algorithm that continually inputs one integer (n) and then displays the result (Un) on screen. The algorithm will be terminated when the input is minus one.

More Related Content

PPT
Flow Chart & Input Output Statement [3] M
PPT
Functions & Procedures [7]
PPTX
Input Output Management In C Programming
PPT
PDF
CP Handout#7
PDF
Chapter 5 exercises Balagurusamy Programming ANSI in c
DOCX
Dam31303 dti2143 lab sheet 7
DOCX
C programming Lab 1
Flow Chart & Input Output Statement [3] M
Functions & Procedures [7]
Input Output Management In C Programming
CP Handout#7
Chapter 5 exercises Balagurusamy Programming ANSI in c
Dam31303 dti2143 lab sheet 7
C programming Lab 1

What's hot (20)

PPTX
FLOW OF CONTROL-NESTED IFS IN PYTHON
PDF
Chapter 3 : Balagurusamy Programming ANSI in C
PDF
7. input and output functions
PDF
Chapter 4 : Balagurusamy Programming ANSI in C
PPTX
Ternary operator
DOCX
Ankita sharma focp
PPT
Mesics lecture 5 input – output in ‘c’
PPT
Stack Data Structure V1.0
RTF
PDF
CP Handout#9
PPT
Mesics lecture 4 c operators and experssions
PPTX
Seminar 2 coding_principles
PPTX
C language operators
PPTX
Seminar 2 coding_principles
PDF
Chapter 6 Balagurusamy Programming ANSI in c
PPTX
Operators
DOCX
Programming fundamentals
PPTX
Managing input and output operations in c
DOCX
C programming Lab 2
PDF
Chapter 2 : Balagurusamy_ Programming ANsI in C
FLOW OF CONTROL-NESTED IFS IN PYTHON
Chapter 3 : Balagurusamy Programming ANSI in C
7. input and output functions
Chapter 4 : Balagurusamy Programming ANSI in C
Ternary operator
Ankita sharma focp
Mesics lecture 5 input – output in ‘c’
Stack Data Structure V1.0
CP Handout#9
Mesics lecture 4 c operators and experssions
Seminar 2 coding_principles
C language operators
Seminar 2 coding_principles
Chapter 6 Balagurusamy Programming ANSI in c
Operators
Programming fundamentals
Managing input and output operations in c
C programming Lab 2
Chapter 2 : Balagurusamy_ Programming ANsI in C
Ad

Similar to Loop Statements [5] M (20)

PDF
Repetition, Basic loop structures, Loop programming techniques
PPT
Mesics lecture 7 iteration and repetitive executions
PDF
Lecture15 comparisonoftheloopcontrolstructures.ppt
PPTX
Small Basic - Branching and Loop
PPTX
Loops c++
DOCX
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
PPT
Loops Do While Arduino Programming Robotics
PPTX
C language (Part 2)
PDF
Chapter 12 Computer Science ( ICS 12).pdf
PDF
While and For Loops
PDF
Programming with matlab session 5 looping
PDF
07 control+structures
PPT
Fundamentals of Programming Chapter 7
PDF
Chapter 3 - Flow of Control Part II.pdf
PPTX
Csci101 lect06 advanced_looping
PDF
Repetations in C
PPT
Iteration
PPTX
matrices_and_loops.pptx
PPT
Project
PDF
ICP - Lecture 9
Repetition, Basic loop structures, Loop programming techniques
Mesics lecture 7 iteration and repetitive executions
Lecture15 comparisonoftheloopcontrolstructures.ppt
Small Basic - Branching and Loop
Loops c++
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
Loops Do While Arduino Programming Robotics
C language (Part 2)
Chapter 12 Computer Science ( ICS 12).pdf
While and For Loops
Programming with matlab session 5 looping
07 control+structures
Fundamentals of Programming Chapter 7
Chapter 3 - Flow of Control Part II.pdf
Csci101 lect06 advanced_looping
Repetations in C
Iteration
matrices_and_loops.pptx
Project
ICP - Lecture 9
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation theory and applications.pdf

Loop Statements [5] M

  • 1. Programming & Algorithm Loop Statements August 07, 2006
  • 2. Array: The Basic An Array is an indexed group of data storage that have the same name and are distinguished from each other by an index (that is a number following the variable name, enclosed in brackets). A single-dimensional array declaration has the following form: typename array_name[size]; Note : The first index of an array is zero .
  • 3. Loop Statement The function is to execute one/some statement(s) several times. There are three loop statements: for statement while…do statement do…while statement
  • 4. The for S tatement Syntax: for ( initial ; condition ; increment ) statement(s);
  • 5. The for S tatement E.g.: Display the words “Welcome to this cruel world..” ten times. for (i ← 0; i ≤ 9; i ← i + 1) output(“Welcome to this cruel world..”)
  • 6. Exercises Create an algorithm that displays numbers (1 to 25) on screen. Create an algorithm that uses loop statements to displays following formation of ‘*’ character on screen. a. b. c.
  • 7. Exercises Create an algorithm that prints the result of X powered by Y. The algorithm received two numbers of integer (X and Y). Create an algorithm that asks one number of integer (N) and displays the numbers of Fibonacci on screen. E.g.: 1 1 2 3 5 8 13 7 Output Input
  • 8. The while S tatement Syntax: while ( condition ) statement(s);
  • 9. The do…while S tatement Syntax: do statement(s); while ( condition );
  • 10. Nested Loops The term nested loops refers to a loop that is contained within another loop.
  • 11. Exercises Create an algorithm that continually inputs one integer (N) and then displays a triangle (N rows). The algorithm will be terminated when the input is zero. E.g.: 4 Output Input
  • 12. Exercises A mathematics' formula is shown by: Sn = (2 * n) + 3 Un = Sn + Sn- 1 + … + S 0 Create an algorithm that continually inputs one integer (n) and then displays the result (Un) on screen. The algorithm will be terminated when the input is minus one.