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); 6 $c
' ' %
– printf(“%d”,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 ' / 1
# 0 ' - 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 ' / 1
• For - while
initialization;
while ( loopContinuationTest){
statement
increment;
}
0 ' / 1
# 2 &
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 : 9%
7 : 8
'
$;1 < =, %8
> Sum is 2550
/
3 4 5
$%
6
,8
$%8
# * . ' '
' D-
,' ?,
' - , -
Enter number of sides: 5
*
**
* *
* *
*****
)
# * . ' '
' D-
,' ?,
' - , -
Enter number of sides: 5
*****
* *
* *
**
*