Home » Archimedes archive » Acorn User » AU 1994-02.adf » !C_Interp_C_Interp » Examples/constructs

Examples/constructs

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1994-02.adf » !C_Interp_C_Interp
Filename: Examples/constructs
Read OK:
File size: 00FC bytes
Load address: 0000
Exec address: 0000
File contents
@* An example of constructs *@

main()
{
int i=5, j=10;

if(i>j && j>6)
  printf("%d\n\n",i);
else
  printf("%d\n\n",j);

@* Loop from 0 to 9 step 1 *@
for(i=0; i<10; i++)
  printf("Loop %d\n",i);

i=0;
while(i<10)
  {
  printf("Loop %d\n",i++);
  }
}
00000000  40 2a 20 41 6e 20 65 78  61 6d 70 6c 65 20 6f 66  |@* An example of|
00000010  20 63 6f 6e 73 74 72 75  63 74 73 20 2a 40 0a 0a  | constructs *@..|
00000020  6d 61 69 6e 28 29 0a 7b  0a 69 6e 74 20 69 3d 35  |main().{.int i=5|
00000030  2c 20 6a 3d 31 30 3b 0a  0a 69 66 28 69 3e 6a 20  |, j=10;..if(i>j |
00000040  26 26 20 6a 3e 36 29 0a  20 20 70 72 69 6e 74 66  |&& j>6).  printf|
00000050  28 22 25 64 5c 6e 5c 6e  22 2c 69 29 3b 0a 65 6c  |("%d\n\n",i);.el|
00000060  73 65 0a 20 20 70 72 69  6e 74 66 28 22 25 64 5c  |se.  printf("%d\|
00000070  6e 5c 6e 22 2c 6a 29 3b  0a 0a 40 2a 20 4c 6f 6f  |n\n",j);..@* Loo|
00000080  70 20 66 72 6f 6d 20 30  20 74 6f 20 39 20 73 74  |p from 0 to 9 st|
00000090  65 70 20 31 20 2a 40 0a  66 6f 72 28 69 3d 30 3b  |ep 1 *@.for(i=0;|
000000a0  20 69 3c 31 30 3b 20 69  2b 2b 29 0a 20 20 70 72  | i<10; i++).  pr|
000000b0  69 6e 74 66 28 22 4c 6f  6f 70 20 25 64 5c 6e 22  |intf("Loop %d\n"|
000000c0  2c 69 29 3b 0a 0a 69 3d  30 3b 0a 77 68 69 6c 65  |,i);..i=0;.while|
000000d0  28 69 3c 31 30 29 0a 20  20 7b 0a 20 20 70 72 69  |(i<10).  {.  pri|
000000e0  6e 74 66 28 22 4c 6f 6f  70 20 25 64 5c 6e 22 2c  |ntf("Loop %d\n",|
000000f0  69 2b 2b 29 3b 0a 20 20  7d 0a 7d 0a              |i++);.  }.}.|
000000fc