Horton Example 5.5 ported to mbed/Nucleo.

Dependencies:   mbed

Committer:
CSTritt
Date:
Wed Oct 25 15:49:34 2017 +0000
Revision:
1:0e73bf50fbf3
Parent:
0:8482415bf245
Added newline after last line of output to get it to display.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 0:8482415bf245 1 /*
CSTritt 0:8482415bf245 2 Project: GradeAverage
CSTritt 0:8482415bf245 3 File: main.cpp
CSTritt 0:8482415bf245 4 Ported to mbed/Nucleo by: Dr. C. S. Tritt
CSTritt 1:0e73bf50fbf3 5 Last revised: 10/22/17 (v. 1.1)
CSTritt 0:8482415bf245 6
CSTritt 0:8482415bf245 7 Program 5.5 Using the & operator - from Beginning C, 5th ed. Ivor Horton.
CSTritt 0:8482415bf245 8
CSTritt 0:8482415bf245 9 */
CSTritt 0:8482415bf245 10 #include "mbed.h"
CSTritt 0:8482415bf245 11
CSTritt 0:8482415bf245 12 int main(void)
CSTritt 0:8482415bf245 13 {
CSTritt 0:8482415bf245 14 // Define some integer variables.
CSTritt 0:8482415bf245 15 int a = 1;
CSTritt 0:8482415bf245 16 int b = 2;
CSTritt 0:8482415bf245 17 int c = 3;
CSTritt 0:8482415bf245 18
CSTritt 0:8482415bf245 19 // Define some floating-point variables.
CSTritt 0:8482415bf245 20 float d = 4.0f;
CSTritt 0:8482415bf245 21 float e = 5.0f;
CSTritt 0:8482415bf245 22 float f = 6.0f;
CSTritt 0:8482415bf245 23
CSTritt 0:8482415bf245 24 printf("\nVariables of type int occupy %u bytes each.", sizeof(int));
CSTritt 0:8482415bf245 25 printf("\nHere are the addresses of some type int variables --");
CSTritt 0:8482415bf245 26 printf("\nThe address of a is: %p.\nThe address of b is: %p.", &a, &b);
CSTritt 0:8482415bf245 27 printf("\nThe address of c is: %p.", &c);
CSTritt 0:8482415bf245 28 printf("\n\nVariables of type float occupy %u bytes each.", sizeof(float));
CSTritt 0:8482415bf245 29 printf("\nHere are the addresses of some type float variables --");
CSTritt 0:8482415bf245 30 printf("\nThe address of d is: %p.\nThe address of e is: %p.", &d, &e);
CSTritt 0:8482415bf245 31 printf("\nThe address of f is: %p.", &f);
CSTritt 1:0e73bf50fbf3 32 printf("\n"); // Necessary to display last line.
CSTritt 0:8482415bf245 33 while (true) {} // Loop forever when done.
CSTritt 0:8482415bf245 34 }