VOOZH about

URL: https://www.geeksforgeeks.org/c/moverel-function-c/

⇱ moverel() function in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

moverel() function in C

Last Updated : 29 Nov, 2019
The header file graphics.h contains moverel() function which moves a point from the current position(x_pos1, y_pos1) to a point that is at a relative distance (x, y) from the Current Position and then advances the Current Position by (x, y). Note : getx and gety can be used to find the current position. Syntax :
moverel(int x, int y);

The end position is calculated as :
x_pos2 = x_pos1 + x;
y_pos2 = y_pos1 + y;
Examples :
Input : x_pos1 = 0, y_pos1 =0, x = 200, y = 100
Output : 👁 Image
Input : x_pos1 = 100, y_pos1 = 150, x = 150, y = 60 Output : 👁 Image
CASE 1 : When the current position is at origin i.e, (0, 0) Below is the implementation of moverel() function in C: Output :
👁 Image
CASE 2 : When the current position is other than origin(100, 150). Below is the implementation of moverel() function in C:
Output :
👁 Image
Comment