Home » Archimedes archive » Acorn User » AU 1994-10.adf » !Extras_Extras » CTutorial/c/HofLords

CTutorial/c/HofLords

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-10.adf » !Extras_Extras
Filename: CTutorial/c/HofLords
Read OK:
File size: 054C bytes
Load address: 0000
Exec address: 0000
File contents
/* Program HofLords, which declares a list of variables and */
/* assigns values to them. In other words, it does nothing  */
/* in particular, and does it very well.                    */
/* by David Matthewmman                                     */

main()
{ char c1,c2,c3,c4;
  int i1,i2,i3,i4;
  short int s1,s2;
  long int l1,l2;
  float f1,f2;
  double d1,d2,d3,d4;
  long double ld1,ld2;

/* Character variables can also have integer values up to 255.     */
  c1 = 'c'; c2 = 105; c3 = '\n'; c4 = '\x3f';

/* The three types of integer variables are all the same size in   */
/* Easy C's implementation.                                        */
/* The cast to int for i3 is not necessary; it will be performed   */
/* automatically, but serves as a reminder - likewise the l after  */
/* l1 and l2.                                                      */
  i1 = 100; i2 = -273; i3 = (int)26.57; i4 = 0x3ffa;
  s1 = -57; s2 = 2147483647;
  l1 = 100l; l2 = 2147483647L;

/* In Easy C, double amd long double variables are the same size,  */
/* and have twice the precision of float. Floating point numbers   */
/* are assumed to be double, unless stated otherwise.              */
  f1 = 0.123456789f; f2 = 1.6e-19F;
  d1 = 0.123456789012345; d2 = -300e25;
  d3 = (double)256; d4 = 12.56E+160;
  ld1 = 0.123456789012345L; ld2=1e+100l;

  return 0;
}
00000000  2f 2a 20 50 72 6f 67 72  61 6d 20 48 6f 66 4c 6f  |/* Program HofLo|
00000010  72 64 73 2c 20 77 68 69  63 68 20 64 65 63 6c 61  |rds, which decla|
00000020  72 65 73 20 61 20 6c 69  73 74 20 6f 66 20 76 61  |res a list of va|
00000030  72 69 61 62 6c 65 73 20  61 6e 64 20 2a 2f 0a 2f  |riables and */./|
00000040  2a 20 61 73 73 69 67 6e  73 20 76 61 6c 75 65 73  |* assigns values|
00000050  20 74 6f 20 74 68 65 6d  2e 20 49 6e 20 6f 74 68  | to them. In oth|
00000060  65 72 20 77 6f 72 64 73  2c 20 69 74 20 64 6f 65  |er words, it doe|
00000070  73 20 6e 6f 74 68 69 6e  67 20 20 2a 2f 0a 2f 2a  |s nothing  */./*|
00000080  20 69 6e 20 70 61 72 74  69 63 75 6c 61 72 2c 20  | in particular, |
00000090  61 6e 64 20 64 6f 65 73  20 69 74 20 76 65 72 79  |and does it very|
000000a0  20 77 65 6c 6c 2e 20 20  20 20 20 20 20 20 20 20  | well.          |
000000b0  20 20 20 20 20 20 20 20  20 20 2a 2f 0a 2f 2a 20  |          */./* |
000000c0  62 79 20 44 61 76 69 64  20 4d 61 74 74 68 65 77  |by David Matthew|
000000d0  6d 6d 61 6e 20 20 20 20  20 20 20 20 20 20 20 20  |mman            |
000000e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000f0  20 20 20 20 20 20 20 20  20 2a 2f 0a 0a 6d 61 69  |         */..mai|
00000100  6e 28 29 0a 7b 20 63 68  61 72 20 63 31 2c 63 32  |n().{ char c1,c2|
00000110  2c 63 33 2c 63 34 3b 0a  20 20 69 6e 74 20 69 31  |,c3,c4;.  int i1|
00000120  2c 69 32 2c 69 33 2c 69  34 3b 0a 20 20 73 68 6f  |,i2,i3,i4;.  sho|
00000130  72 74 20 69 6e 74 20 73  31 2c 73 32 3b 0a 20 20  |rt int s1,s2;.  |
00000140  6c 6f 6e 67 20 69 6e 74  20 6c 31 2c 6c 32 3b 0a  |long int l1,l2;.|
00000150  20 20 66 6c 6f 61 74 20  66 31 2c 66 32 3b 0a 20  |  float f1,f2;. |
00000160  20 64 6f 75 62 6c 65 20  64 31 2c 64 32 2c 64 33  | double d1,d2,d3|
00000170  2c 64 34 3b 0a 20 20 6c  6f 6e 67 20 64 6f 75 62  |,d4;.  long doub|
00000180  6c 65 20 6c 64 31 2c 6c  64 32 3b 0a 0a 2f 2a 20  |le ld1,ld2;../* |
00000190  43 68 61 72 61 63 74 65  72 20 76 61 72 69 61 62  |Character variab|
000001a0  6c 65 73 20 63 61 6e 20  61 6c 73 6f 20 68 61 76  |les can also hav|
000001b0  65 20 69 6e 74 65 67 65  72 20 76 61 6c 75 65 73  |e integer values|
000001c0  20 75 70 20 74 6f 20 32  35 35 2e 20 20 20 20 20  | up to 255.     |
000001d0  2a 2f 0a 20 20 63 31 20  3d 20 27 63 27 3b 20 63  |*/.  c1 = 'c'; c|
000001e0  32 20 3d 20 31 30 35 3b  20 63 33 20 3d 20 27 5c  |2 = 105; c3 = '\|
000001f0  6e 27 3b 20 63 34 20 3d  20 27 5c 78 33 66 27 3b  |n'; c4 = '\x3f';|
00000200  0a 0a 2f 2a 20 54 68 65  20 74 68 72 65 65 20 74  |../* The three t|
00000210  79 70 65 73 20 6f 66 20  69 6e 74 65 67 65 72 20  |ypes of integer |
00000220  76 61 72 69 61 62 6c 65  73 20 61 72 65 20 61 6c  |variables are al|
00000230  6c 20 74 68 65 20 73 61  6d 65 20 73 69 7a 65 20  |l the same size |
00000240  69 6e 20 20 20 2a 2f 0a  2f 2a 20 45 61 73 79 20  |in   */./* Easy |
00000250  43 27 73 20 69 6d 70 6c  65 6d 65 6e 74 61 74 69  |C's implementati|
00000260  6f 6e 2e 20 20 20 20 20  20 20 20 20 20 20 20 20  |on.             |
00000270  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000280  20 20 20 20 20 20 20 20  20 20 20 2a 2f 0a 2f 2a  |           */./*|
00000290  20 54 68 65 20 63 61 73  74 20 74 6f 20 69 6e 74  | The cast to int|
000002a0  20 66 6f 72 20 69 33 20  69 73 20 6e 6f 74 20 6e  | for i3 is not n|
000002b0  65 63 65 73 73 61 72 79  3b 20 69 74 20 77 69 6c  |ecessary; it wil|
000002c0  6c 20 62 65 20 70 65 72  66 6f 72 6d 65 64 20 20  |l be performed  |
000002d0  20 2a 2f 0a 2f 2a 20 61  75 74 6f 6d 61 74 69 63  | */./* automatic|
000002e0  61 6c 6c 79 2c 20 62 75  74 20 73 65 72 76 65 73  |ally, but serves|
000002f0  20 61 73 20 61 20 72 65  6d 69 6e 64 65 72 20 2d  | as a reminder -|
00000300  20 6c 69 6b 65 77 69 73  65 20 74 68 65 20 6c 20  | likewise the l |
00000310  61 66 74 65 72 20 20 2a  2f 0a 2f 2a 20 6c 31 20  |after  */./* l1 |
00000320  61 6e 64 20 6c 32 2e 20  20 20 20 20 20 20 20 20  |and l2.         |
00000330  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000350  20 20 20 20 20 20 20 20  20 20 20 20 20 2a 2f 0a  |             */.|
00000360  20 20 69 31 20 3d 20 31  30 30 3b 20 69 32 20 3d  |  i1 = 100; i2 =|
00000370  20 2d 32 37 33 3b 20 69  33 20 3d 20 28 69 6e 74  | -273; i3 = (int|
00000380  29 32 36 2e 35 37 3b 20  69 34 20 3d 20 30 78 33  |)26.57; i4 = 0x3|
00000390  66 66 61 3b 0a 20 20 73  31 20 3d 20 2d 35 37 3b  |ffa;.  s1 = -57;|
000003a0  20 73 32 20 3d 20 32 31  34 37 34 38 33 36 34 37  | s2 = 2147483647|
000003b0  3b 0a 20 20 6c 31 20 3d  20 31 30 30 6c 3b 20 6c  |;.  l1 = 100l; l|
000003c0  32 20 3d 20 32 31 34 37  34 38 33 36 34 37 4c 3b  |2 = 2147483647L;|
000003d0  0a 0a 2f 2a 20 49 6e 20  45 61 73 79 20 43 2c 20  |../* In Easy C, |
000003e0  64 6f 75 62 6c 65 20 61  6d 64 20 6c 6f 6e 67 20  |double amd long |
000003f0  64 6f 75 62 6c 65 20 76  61 72 69 61 62 6c 65 73  |double variables|
00000400  20 61 72 65 20 74 68 65  20 73 61 6d 65 20 73 69  | are the same si|
00000410  7a 65 2c 20 20 2a 2f 0a  2f 2a 20 61 6e 64 20 68  |ze,  */./* and h|
00000420  61 76 65 20 74 77 69 63  65 20 74 68 65 20 70 72  |ave twice the pr|
00000430  65 63 69 73 69 6f 6e 20  6f 66 20 66 6c 6f 61 74  |ecision of float|
00000440  2e 20 46 6c 6f 61 74 69  6e 67 20 70 6f 69 6e 74  |. Floating point|
00000450  20 6e 75 6d 62 65 72 73  20 20 20 2a 2f 0a 2f 2a  | numbers   */./*|
00000460  20 61 72 65 20 61 73 73  75 6d 65 64 20 74 6f 20  | are assumed to |
00000470  62 65 20 64 6f 75 62 6c  65 2c 20 75 6e 6c 65 73  |be double, unles|
00000480  73 20 73 74 61 74 65 64  20 6f 74 68 65 72 77 69  |s stated otherwi|
00000490  73 65 2e 20 20 20 20 20  20 20 20 20 20 20 20 20  |se.             |
000004a0  20 2a 2f 0a 20 20 66 31  20 3d 20 30 2e 31 32 33  | */.  f1 = 0.123|
000004b0  34 35 36 37 38 39 66 3b  20 66 32 20 3d 20 31 2e  |456789f; f2 = 1.|
000004c0  36 65 2d 31 39 46 3b 0a  20 20 64 31 20 3d 20 30  |6e-19F;.  d1 = 0|
000004d0  2e 31 32 33 34 35 36 37  38 39 30 31 32 33 34 35  |.123456789012345|
000004e0  3b 20 64 32 20 3d 20 2d  33 30 30 65 32 35 3b 0a  |; d2 = -300e25;.|
000004f0  20 20 64 33 20 3d 20 28  64 6f 75 62 6c 65 29 32  |  d3 = (double)2|
00000500  35 36 3b 20 64 34 20 3d  20 31 32 2e 35 36 45 2b  |56; d4 = 12.56E+|
00000510  31 36 30 3b 0a 20 20 6c  64 31 20 3d 20 30 2e 31  |160;.  ld1 = 0.1|
00000520  32 33 34 35 36 37 38 39  30 31 32 33 34 35 4c 3b  |23456789012345L;|
00000530  20 6c 64 32 3d 31 65 2b  31 30 30 6c 3b 0a 0a 20  | ld2=1e+100l;.. |
00000540  20 72 65 74 75 72 6e 20  30 3b 0a 7d              | return 0;.}|
0000054c