Puzzle T15

Point

Define a struct type, using typedef, for a point in 2D computer graphics. A point consists of an integer pair, (X, Y) for a point in the 2D plane. Values can be negative, zero, or positive integer.

/* declare the Point type */

/* function to print a Point */
void printPoint( Point *p ) {...}

int main()
{
  /* declare and initialize two Points */
  Point p1={-32,77}, p2={345, 490};

  /* print values */
  printPoint( &p1 );
  printPoint( &p2 );
    
  return 0;
} 


Previous Page        Answer         Next Page         Home