home *** CD-ROM | disk | FTP | other *** search
- 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;
- }
- }
- }
-