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.
Revision 0:a99225f444c5, committed 2017-10-23
- Comitter:
- CSTritt
- Date:
- Mon Oct 23 01:22:05 2017 +0000
- Commit message:
- Initial version.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r a99225f444c5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 23 01:22:05 2017 +0000 @@ -0,0 +1,33 @@ +/* + Project: GradeAverage + File: main.cpp + Ported to mbed/Nucleo by: Dr. C. S. Tritt + Last revised: 10/22/17 (v. 1.0) + + Program 5.3 Averaging grades - from Beginning C, 5th ed. Ivor Horton. + +*/ +#include "mbed.h" + +const int SIZE = 5; // This is the number of grades. + +int main(void) +{ + float grades[SIZE]; // Create array for storing values. + float sum = 0.0f; // Initialize running sum of grades. + + printf("\nAssure Terminal > local echo is on.\n"); + printf("\nEnter five grades (1 at a time):\n"); // Prompt for the input. + + // Read the ten numbers to be averaged + for(unsigned int i = 0 ; i < SIZE ; ++i) { + printf("%2u> ", i + 1); // Display a prompt. + // Read a grade. Danger. Always guard against array overflow on input. + scanf("%f", &grades[i]); // Read ith value. Pass by reference. + sum += grades[i]; // Keep a running sum. + } + // Calculate the average. Cast is optional. + float average = sum / (float) SIZE; + printf("\nThe average of the entered grades is: %.2f\n", average); + while (true) {} // Loop forever when done. Reset to start over. +} \ No newline at end of file
diff -r 000000000000 -r a99225f444c5 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 23 01:22:05 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302 \ No newline at end of file