Andy Pomfret / Mbed OS UoY-32C-lab4-2

Dependencies:   UoY-serial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 struct IntVector {
00004   int x;
00005   int y;
00006 };
00007 
00008 unsigned long long modSquared(IntVector vector) {
00009     return vector.x*vector.x + vector.y*vector.y;
00010 }
00011 
00012 int main() {
00013   IntVector p;
00014   IntVector q;
00015   
00016   p.x = -3;
00017   p.y = 1;
00018   
00019   q = p;
00020   q.x = 4;
00021   
00022   printf("(%d, %d).  Mod-squared %llu\r\n", q.x, q.y, modSquared(q));
00023   printf("(%d, %d).  Mod-squared %llu\r\n", p.x, p.y, modSquared(p));
00024   
00025   // Do nothing, forever...
00026   while (true);
00027 }