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 Task138 by
main.cpp@2:07b089e14332, 2019-09-11 (annotated)
- Committer:
- noutram
- Date:
- Wed Sep 11 14:26:19 2019 +0000
- Revision:
- 2:07b089e14332
- Parent:
- 0:c401fd4ffbe7
2019;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| noutram | 0:c401fd4ffbe7 | 1 | #include "mbed.h" |
| noutram | 0:c401fd4ffbe7 | 2 | |
| noutram | 0:c401fd4ffbe7 | 3 | Serial pc(SERIAL_TX, SERIAL_RX); |
| noutram | 0:c401fd4ffbe7 | 4 | |
| noutram | 0:c401fd4ffbe7 | 5 | char nameStr[30]; |
| noutram | 0:c401fd4ffbe7 | 6 | int age = 1; |
| noutram | 0:c401fd4ffbe7 | 7 | |
| noutram | 0:c401fd4ffbe7 | 8 | void getData() |
| noutram | 0:c401fd4ffbe7 | 9 | { |
| noutram | 0:c401fd4ffbe7 | 10 | pc.scanf("%s %d", &nameStr, &age); |
| noutram | 0:c401fd4ffbe7 | 11 | } |
| noutram | 0:c401fd4ffbe7 | 12 | |
| noutram | 0:c401fd4ffbe7 | 13 | void printData() |
| noutram | 0:c401fd4ffbe7 | 14 | { |
| noutram | 0:c401fd4ffbe7 | 15 | pc.printf("Hello %s \n\r", nameStr); |
| noutram | 0:c401fd4ffbe7 | 16 | pc.printf("You are %d \n\r", age); |
| noutram | 0:c401fd4ffbe7 | 17 | } |
| noutram | 0:c401fd4ffbe7 | 18 | |
| noutram | 0:c401fd4ffbe7 | 19 | int main() |
| noutram | 0:c401fd4ffbe7 | 20 | { |
| noutram | 0:c401fd4ffbe7 | 21 | int counter = 0; |
| noutram | 0:c401fd4ffbe7 | 22 | while (age > 0) |
| noutram | 0:c401fd4ffbe7 | 23 | { |
| noutram | 0:c401fd4ffbe7 | 24 | getData(); |
| noutram | 0:c401fd4ffbe7 | 25 | printData(); |
| noutram | 0:c401fd4ffbe7 | 26 | counter++; |
| noutram | 0:c401fd4ffbe7 | 27 | } |
| noutram | 0:c401fd4ffbe7 | 28 | pc.printf("You entered %d names\n", counter); |
| noutram | 0:c401fd4ffbe7 | 29 | sleep(); |
| noutram | 0:c401fd4ffbe7 | 30 | } |
