• Have Any Question?
  • contact@eitworld.com

Moverel() Function





moverel() function is used to move the c.p (current position) by a relative distance from its current position at that time. moverel() function can use with the linerel() function in order to draw the line. linerel() is already discussed in the previous section.

Declaration

void moverel(int x, int y);
  • moverel() function contains two parameter. First parameter specifies the X-coordinate.
  • Second parameter specifies the Y-coordinate.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd = DETECT, gm, x, y;

char arr[100];

initgraph(&gd, &gm, ” “);

x = getx();

y = gety();

sprintf(arr, “Current position before using moveto() function is (%d,%d).”, x, y);

outtextxy(100,200, arr);

moveto(100, 100);

x = getx();

y = gety();

sprintf(arr, “Current position after using moveto() function is (%d,%d).”, x, y);

outtextxy(100,240, arr);

moverel(100, -100);

x = getx();

y = gety();

sprintf(arr, “Current position after using moverel() function is (%d,%d).”, x, y);

outtextxy(100,280, arr);

getch();

closegraph();

}

Above program tells us the role of the moverel() function. This function will move the current position to the new current position related to previous one. In the above program moveto() function move the current position to a new position (100,100). After that movrel() function moves the current position with a relative distance. In the above program moverel(100,-100) moves the current position at a new position (200,0) which is related to previous one.

Output

c graphics



Real Time Web Analytics