home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d110
/
pdc.lha
/
Pdc
/
examples
/
logic.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-10-28
|
888b
|
63 lines
main()
{
/*
* Test out logic statements
*/
int i;
/* for loop */
for ( i=0; i < 3; ++i)
printf("for: i = %ld of 3\n", i );
/*
* while loop
*/
i = 0;
while ( i < 3 )
{
printf("while: i = %ld of 3\n", i );
++i;
}
/*
* do until
*/
i = 0;
do
{
printf("do until: i = %ld of 3\n", i);
++i;
}
while( i < 3 );
/*
* if ... then ... else
*/
i = 3;
if ( i < 3 )
printf("if: i = %ld < 3 Test Ok\n", i);
else
printf("if: i = %ld < 3 Test false\n", i);
/*
* switch statement.
*/
for ( i = 0; i < 4; i++ )
{
switch(i)
{
case 0: printf("At Case 0: i=%ld\n", i);
break;
case 1: printf("At Case 1: i=%ld\n", i);
break;
case 2: printf("At Case 2: i=%ld\n", i);
break;
default: printf("At default: i=%ld\n", i);
break;
}
}
}