Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of aReadConditional by
main.cpp@5:198bfb6c4a3b, 2017-09-25 (annotated)
- Committer:
- CSTritt
- Date:
- Mon Sep 25 15:09:48 2017 +0000
- Revision:
- 5:198bfb6c4a3b
- Parent:
- 4:acc6be2bbe21
Initial version.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| CSTritt | 0:2254358fce87 | 1 | /* |
| CSTritt | 5:198bfb6c4a3b | 2 | Project: PowOf3 |
| CSTritt | 0:2254358fce87 | 3 | File: main.cpp |
| CSTritt | 0:2254358fce87 | 4 | |
| CSTritt | 5:198bfb6c4a3b | 5 | Simple powers of 3 program. Demonstrates for loops and arrays. |
| CSTritt | 5:198bfb6c4a3b | 6 | |
| CSTritt | 0:2254358fce87 | 7 | Written by: Dr. C. S. Tritt |
| CSTritt | 5:198bfb6c4a3b | 8 | Created: 9/25/17 (v. 1.0) |
| CSTritt | 0:2254358fce87 | 9 | |
| CSTritt | 0:2254358fce87 | 10 | */ |
| CSTritt | 0:2254358fce87 | 11 | #include "mbed.h" |
| CSTritt | 0:2254358fce87 | 12 | |
| CSTritt | 5:198bfb6c4a3b | 13 | Serial pc(USBTX, NC, 9600); // Serial transmit only @ 9600 baud. |
| CSTritt | 3:0756601ff19e | 14 | AnalogIn analog_value(A0); // Construct AnalogIn object called analog_value. |
| CSTritt | 0:2254358fce87 | 15 | |
| CSTritt | 0:2254358fce87 | 16 | int main() { |
| CSTritt | 5:198bfb6c4a3b | 17 | |
| CSTritt | 5:198bfb6c4a3b | 18 | printf("\nPowers of 3 Demonstration (v. 1.0)\n"); // Identify program. |
| CSTritt | 0:2254358fce87 | 19 | |
| CSTritt | 5:198bfb6c4a3b | 20 | const int SIZE = 10; // Number of array elements. |
| CSTritt | 0:2254358fce87 | 21 | |
| CSTritt | 5:198bfb6c4a3b | 22 | int i; // Loop counter. |
| CSTritt | 5:198bfb6c4a3b | 23 | int p[SIZE]; // Number of elements. |
| CSTritt | 5:198bfb6c4a3b | 24 | |
| CSTritt | 5:198bfb6c4a3b | 25 | for(i = 0; i <= SIZE - 1; i++) { |
| CSTritt | 5:198bfb6c4a3b | 26 | p[i] = (int) pow(3.0, (double) i); |
| CSTritt | 5:198bfb6c4a3b | 27 | pc.printf(" i = %i and 3^i = %i.\n", i, p[i]); |
| CSTritt | 0:2254358fce87 | 28 | } |
| CSTritt | 4:acc6be2bbe21 | 29 | } |
