09 Es26 Lab - Loops 2

  • Uploaded by: Wilmarc
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 09 Es26 Lab - Loops 2 as PDF for free.

More details

  • Words: 353
  • Pages: 17
for (init; cond; end) { block}

init; while (cond) { block; end; }

for (i=1; i <= 10; i++) { printf("%d\n", i); }

! # c = c+1 # ! c = c - 1 () # * c% # +

"

$++% &

'

$-- %&

'

'

$++c



,

() # * -% #

'

$c++ ,

c-

!

"

() #*

'

$++c

–c% #+

,

() #* -- % c #

'

$c++ ,

! # 'c = 5, – printf(“%d”,++c); ' ' – printf(“%d”,c++); ' '%

" 6 $c % 5$

' -

! # * + () ' ' ++c; printf(“%d”, c); c++; printf(“%d”,c);

' '

"

'. / # . (0

&.

& '

$

% (0 (0 ' (0

'

$

' ' $ ,% % '

'. /

&.

# int counter =1; /*initialization */ while (counter <= 10){ /* repetition condition */ printf(“%d \n”, counter); ++counter; /*increment */

}

0 ' / # 0

'

-

1 for

for (initialization;LoopContinuationTest; increment )

statement

0 ' /

1

# int counter; for(counter=1; counter<= 10; counter++) Printf(“%d \n”, counter);

()

'

No semicolon after last statement

0 ' / • For

1 -

while

initialization; while ( loopContinuationTest){ statement increment; }

0 ' / #

2

1 &

int I; for(i=0, j=0; j+i <= 10; j++, i++) printf(“%d \n”, j + i);

' 1 • Program to sum the even numbers from 2 to 100 3

4

5

$% 6 7 , 8 ' $ 798 47 8 7 : 8 ' $; 1 < = , %8 >

Sum is 2550

7

: 9%

/ 3

4

5

$% 6 ,8 $%8 ' $ 7 8 4?8 ::%6 ' $ 7 8 4@8 ::% ' $A BA %8 ' $A C A %8 > >

) # *

. ' ,'

?, ' , Enter number of sides: 5 * ** * * * * *****

' D-

'

) # *

. ' ,'

?, ' , Enter number of sides: 5 ***** * * * * ** *

' D-

'

Related Documents

09 Es26 Lab - Loops 2
May 2020 14
08 Es26 Lab - Loops
May 2020 6
11 Es26 Lab - Arrays
May 2020 14
Loops
May 2020 15

More Documents from "Jenny Rose G. Sison"

Mscsgradapp
May 2020 8
09 Es26 Lab - Loops 2
May 2020 14
11 Es26 Lab - Arrays
May 2020 14
08 Es26 Lab - Loops
May 2020 6
13 Es 26 - Strings
May 2020 4