Declaring a 2D coordinate in Perl / C / C++ [closed]

For C/C++, you can create a structure to hold a x and y value.

typedef struct {
    double x;
    double y;
} Coordinate;

Inside your main function, you can initialize it like that:

Coordinate treasure = {1.5, 3.2};

To modify a variable’s value:

treasure.x = 3.0;
treasure.y = 4.0;

Leave a Comment