Home » Archimedes archive » Acorn Computing » 1995 02 subscription disc.adf » 9502s » C++/MorePrint
C++/MorePrint
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 Computing » 1995 02 subscription disc.adf » 9502s |
Filename: | C++/MorePrint |
Read OK: | ✔ |
File size: | 0187 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
// Mixing variable types with the << operator #include <iostream.h> main() { int x = 12; int y = 14; cout << "The << operator doesn't stop at strings...\n\n"; cout << "It can print numbers: " << x << "\n"; cout << "And perform arithmetic: " << x << "+" << y << "= " << x+y << "\n"; cout << "In fact, it can do almost anything!\n"; }
00000000 2f 2f 20 4d 69 78 69 6e 67 20 76 61 72 69 61 62 |// Mixing variab| 00000010 6c 65 20 74 79 70 65 73 20 77 69 74 68 20 74 68 |le types with th| 00000020 65 20 3c 3c 20 6f 70 65 72 61 74 6f 72 0a 0a 23 |e << operator..#| 00000030 69 6e 63 6c 75 64 65 20 3c 69 6f 73 74 72 65 61 |include <iostrea| 00000040 6d 2e 68 3e 0a 0a 6d 61 69 6e 28 29 0a 7b 0a 20 |m.h>..main().{. | 00000050 20 20 20 20 20 20 20 69 6e 74 20 20 20 20 20 78 | int x| 00000060 20 3d 20 31 32 3b 0a 20 20 20 20 20 20 20 20 69 | = 12;. i| 00000070 6e 74 20 20 20 20 20 79 20 3d 20 31 34 3b 0a 20 |nt y = 14;. | 00000080 20 20 20 20 20 20 20 63 6f 75 74 20 3c 3c 20 22 | cout << "| 00000090 54 68 65 20 3c 3c 20 6f 70 65 72 61 74 6f 72 20 |The << operator | 000000a0 64 6f 65 73 6e 27 74 20 73 74 6f 70 20 61 74 20 |doesn't stop at | 000000b0 73 74 72 69 6e 67 73 2e 2e 2e 5c 6e 5c 6e 22 3b |strings...\n\n";| 000000c0 0a 20 20 20 20 20 20 20 20 63 6f 75 74 20 3c 3c |. cout <<| 000000d0 20 22 49 74 20 63 61 6e 20 70 72 69 6e 74 20 6e | "It can print n| 000000e0 75 6d 62 65 72 73 3a 20 22 20 3c 3c 20 78 20 3c |umbers: " << x <| 000000f0 3c 20 22 5c 6e 22 3b 0a 20 20 20 20 20 20 20 20 |< "\n";. | 00000100 63 6f 75 74 20 3c 3c 20 22 41 6e 64 20 70 65 72 |cout << "And per| 00000110 66 6f 72 6d 20 61 72 69 74 68 6d 65 74 69 63 3a |form arithmetic:| 00000120 20 22 20 3c 3c 20 78 20 3c 3c 20 22 2b 22 20 3c | " << x << "+" <| 00000130 3c 20 79 20 3c 3c 20 22 3d 20 22 20 3c 3c 20 78 |< y << "= " << x| 00000140 2b 79 20 3c 3c 20 22 5c 6e 22 3b 0a 20 20 20 20 |+y << "\n";. | 00000150 20 20 20 20 63 6f 75 74 20 3c 3c 20 22 49 6e 20 | cout << "In | 00000160 66 61 63 74 2c 20 69 74 20 63 61 6e 20 64 6f 20 |fact, it can do | 00000170 61 6c 6d 6f 73 74 20 61 6e 79 74 68 69 6e 67 21 |almost anything!| 00000180 5c 6e 22 3b 0a 7d 0a |\n";.}.| 00000187