Charles Tritt / Mbed 2 deprecated PowOf3

Dependencies:   mbed

Fork of aReadConditional by Charles Tritt

main.cpp

Committer:
CSTritt
Date:
2017-09-25
Revision:
5:198bfb6c4a3b
Parent:
4:acc6be2bbe21

File content as of revision 5:198bfb6c4a3b:

/*
    Project: PowOf3
    File: main.cpp
    
    Simple powers of 3 program. Demonstrates for loops and arrays.
  
    Written by: Dr. C. S. Tritt
    Created: 9/25/17 (v. 1.0)
    
*/
#include "mbed.h"

Serial pc(USBTX, NC, 9600); // Serial transmit only @ 9600 baud.
AnalogIn analog_value(A0); // Construct AnalogIn object called analog_value.

int main() {
     
    printf("\nPowers of 3 Demonstration (v. 1.0)\n"); // Identify program.
    
    const int SIZE = 10; // Number of array elements.
    
    int i; // Loop counter.
    int p[SIZE]; // Number of elements.
    
    for(i = 0; i <= SIZE - 1; i++) {
        p[i] = (int) pow(3.0, (double) i);
        pc.printf(" i = %i and 3^i = %i.\n", i, p[i]);
    }
}