Back

/* gcc -o test test.c -l */
#include<stdio.h>
#include<math.h>

struct point
 {
   int x;
   int y;
 };

struct rect
 {
   struct point pt1;
   struct point pt2;
 };

struct point pt;
struct rect screen = { {0,0,},{8,16} };

int main()
{
  double dist;
  pt.x=5, pt.y=10;
  printf("%d,%d\n", pt.x, pt.y);

  dist = sqrt((double)pt.x*pt.x + (double)pt.y*pt.y);
  printf("Distance from origin: %.2f\n",dist);

  printf("%d,%d\n",screen.pt1.x, screen.pt2.x);
  printf("%d,%d\n",screen.pt1.y, screen.pt2.y);
  return 0;
}

Top