Basic Structures - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Basic Structures

Description:

Basic Structures Structured Programming in C++/C sequence decision/selection/testing iteration/repetition/looping Statement: while - loop Example: while-loop ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 7
Provided by: MingM2
Category:

less

Transcript and Presenter's Notes

Title: Basic Structures


1
Basic Structures
  • Structured Programming in C/C
  • sequence
  • decision/selection/testing
  • iteration/repetition/looping

2
Statement while - loop
Flowchart
Syntax
3
Example while-loop
int i //declare an integer counter variable i i
0 //(1) initialization of counter variable
i while ( i lt 10 ) //(2) check condition //do
tasks i i 1 //(3) adjust condition //end
of for-loop
4
Statement for - loop
Flowchart
Syntax
5
Example for-loop
int i //declare an integer counter variable
i for ( i 0 i lt 10 i i 1) //do tasks
//end of for-loop
6
for-loop VS while-loop
  • The for-loop is preferred if using a counter is
    needed.
  • Both has the following basic steps
  • Initialization of condition
  • Check condition
  • Adjust condition
Write a Comment
User Comments (0)
About PowerShow.com