Home » Archimedes archive » Acorn User » AU 1994-11.adf » !C/!Help

!C/!Help

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-11.adf
Filename: !C/!Help
Read OK:
File size: 0332 bytes
Load address: FFFFFF45
Exec address: 9497F4F2
File contents
C Tutorial
by David Matthewman

This archive contains two programs to accompany the C tutorial in the magazine. In both cases the source code for the programs is in the �c� directory, with the executable program itself in the root directory of the archive (provided for those of you without a C compiler).

The Arithmetic program takes two variables and performs all the binary operations mentioned in the article on them. Thus the different results of all the various operations can be seen. Note that in order to perform a floating-point division, one of the integer operands needed to be cast to a floating-point number.

The Precedence program demonstrates the precedence of various operators. Try to work out what the result should be from the source code befor running the program.

� Copyright Acorn User 1994

00000000  43 20 54 75 74 6f 72 69  61 6c 0a 62 79 20 44 61  |C Tutorial.by Da|
00000010  76 69 64 20 4d 61 74 74  68 65 77 6d 61 6e 0a 0a  |vid Matthewman..|
00000020  54 68 69 73 20 61 72 63  68 69 76 65 20 63 6f 6e  |This archive con|
00000030  74 61 69 6e 73 20 74 77  6f 20 70 72 6f 67 72 61  |tains two progra|
00000040  6d 73 20 74 6f 20 61 63  63 6f 6d 70 61 6e 79 20  |ms to accompany |
00000050  74 68 65 20 43 20 74 75  74 6f 72 69 61 6c 20 69  |the C tutorial i|
00000060  6e 20 74 68 65 20 6d 61  67 61 7a 69 6e 65 2e 20  |n the magazine. |
00000070  49 6e 20 62 6f 74 68 20  63 61 73 65 73 20 74 68  |In both cases th|
00000080  65 20 73 6f 75 72 63 65  20 63 6f 64 65 20 66 6f  |e source code fo|
00000090  72 20 74 68 65 20 70 72  6f 67 72 61 6d 73 20 69  |r the programs i|
000000a0  73 20 69 6e 20 74 68 65  20 90 63 91 20 64 69 72  |s in the .c. dir|
000000b0  65 63 74 6f 72 79 2c 20  77 69 74 68 20 74 68 65  |ectory, with the|
000000c0  20 65 78 65 63 75 74 61  62 6c 65 20 70 72 6f 67  | executable prog|
000000d0  72 61 6d 20 69 74 73 65  6c 66 20 69 6e 20 74 68  |ram itself in th|
000000e0  65 20 72 6f 6f 74 20 64  69 72 65 63 74 6f 72 79  |e root directory|
000000f0  20 6f 66 20 74 68 65 20  61 72 63 68 69 76 65 20  | of the archive |
00000100  28 70 72 6f 76 69 64 65  64 20 66 6f 72 20 74 68  |(provided for th|
00000110  6f 73 65 20 6f 66 20 79  6f 75 20 77 69 74 68 6f  |ose of you witho|
00000120  75 74 20 61 20 43 20 63  6f 6d 70 69 6c 65 72 29  |ut a C compiler)|
00000130  2e 0a 0a 54 68 65 20 41  72 69 74 68 6d 65 74 69  |...The Arithmeti|
00000140  63 20 70 72 6f 67 72 61  6d 20 74 61 6b 65 73 20  |c program takes |
00000150  74 77 6f 20 76 61 72 69  61 62 6c 65 73 20 61 6e  |two variables an|
00000160  64 20 70 65 72 66 6f 72  6d 73 20 61 6c 6c 20 74  |d performs all t|
00000170  68 65 20 62 69 6e 61 72  79 20 6f 70 65 72 61 74  |he binary operat|
00000180  69 6f 6e 73 20 6d 65 6e  74 69 6f 6e 65 64 20 69  |ions mentioned i|
00000190  6e 20 74 68 65 20 61 72  74 69 63 6c 65 20 6f 6e  |n the article on|
000001a0  20 74 68 65 6d 2e 20 54  68 75 73 20 74 68 65 20  | them. Thus the |
000001b0  64 69 66 66 65 72 65 6e  74 20 72 65 73 75 6c 74  |different result|
000001c0  73 20 6f 66 20 61 6c 6c  20 74 68 65 20 76 61 72  |s of all the var|
000001d0  69 6f 75 73 20 6f 70 65  72 61 74 69 6f 6e 73 20  |ious operations |
000001e0  63 61 6e 20 62 65 20 73  65 65 6e 2e 20 4e 6f 74  |can be seen. Not|
000001f0  65 20 74 68 61 74 20 69  6e 20 6f 72 64 65 72 20  |e that in order |
00000200  74 6f 20 70 65 72 66 6f  72 6d 20 61 20 66 6c 6f  |to perform a flo|
00000210  61 74 69 6e 67 2d 70 6f  69 6e 74 20 64 69 76 69  |ating-point divi|
00000220  73 69 6f 6e 2c 20 6f 6e  65 20 6f 66 20 74 68 65  |sion, one of the|
00000230  20 69 6e 74 65 67 65 72  20 6f 70 65 72 61 6e 64  | integer operand|
00000240  73 20 6e 65 65 64 65 64  20 74 6f 20 62 65 20 63  |s needed to be c|
00000250  61 73 74 20 74 6f 20 61  20 66 6c 6f 61 74 69 6e  |ast to a floatin|
00000260  67 2d 70 6f 69 6e 74 20  6e 75 6d 62 65 72 2e 0a  |g-point number..|
00000270  0a 54 68 65 20 50 72 65  63 65 64 65 6e 63 65 20  |.The Precedence |
00000280  70 72 6f 67 72 61 6d 20  64 65 6d 6f 6e 73 74 72  |program demonstr|
00000290  61 74 65 73 20 74 68 65  20 70 72 65 63 65 64 65  |ates the precede|
000002a0  6e 63 65 20 6f 66 20 76  61 72 69 6f 75 73 20 6f  |nce of various o|
000002b0  70 65 72 61 74 6f 72 73  2e 20 54 72 79 20 74 6f  |perators. Try to|
000002c0  20 77 6f 72 6b 20 6f 75  74 20 77 68 61 74 20 74  | work out what t|
000002d0  68 65 20 72 65 73 75 6c  74 20 73 68 6f 75 6c 64  |he result should|
000002e0  20 62 65 20 66 72 6f 6d  20 74 68 65 20 73 6f 75  | be from the sou|
000002f0  72 63 65 20 63 6f 64 65  20 62 65 66 6f 72 20 72  |rce code befor r|
00000300  75 6e 6e 69 6e 67 20 74  68 65 20 70 72 6f 67 72  |unning the progr|
00000310  61 6d 2e 0a 0a a9 20 43  6f 70 79 72 69 67 68 74  |am.... Copyright|
00000320  20 41 63 6f 72 6e 20 55  73 65 72 20 31 39 39 34  | Acorn User 1994|
00000330  0a 0a                                             |..|
00000332