Template project for University of York ELE00032C Lab 4

Dependencies:   UoY-serial

main.cpp

Committer:
ajp109
Date:
2021-12-17
Revision:
3:5c16861db08e
Parent:
2:3e6493621bc9

File content as of revision 3:5c16861db08e:

#include "mbed.h"

struct IntVector {
  int x;
  int y;
};

unsigned long long modSquared(IntVector vector) {
    return vector.x*vector.x + vector.y*vector.y;
}

int main() {
  IntVector p;
  IntVector q;
  
  p.x = -3;
  p.y = 1;
  
  q = p;
  q.x = 4;
  
  printf("(%d, %d).  Mod-squared %llu\r\n", q.x, q.y, modSquared(q));
  printf("(%d, %d).  Mod-squared %llu\r\n", p.x, p.y, modSquared(p));
  
  // Do nothing, forever...
  while (true);
}