Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<conio.h>
- #include<graphics.h>
- #include<time.h>
- int main()
- {
- int gd=DETECT,gm;
- initgraph (&gd,&gm,"");
- float x, y, x1, y1, x2, y2, dx, dy, step;
- int i;
- printf("Enter x1 and y1:\n");
- scanf ("%f %f", &x1, &y1);
- printf("Enter x2 and y2:\n");
- scanf ("%f %f", &x2, &y2);
- dx = (x2 - x1);
- dy = (y2 - y1);
- if(dx >= dy)
- {
- step = dx;
- }
- else
- step = dy;
- dx = dx/step;
- dy = dy/step;
- x = x1;
- y = y1;
- printf("Values of x and y:\n ");
- for(i = 1;i <= step; i++)
- {
- x = x + dx;
- y = y + dy;
- printf("%f %f \n", round(x) , round(y));
- putpixel(round(x) , round(y),WHITE);
- delay(10);
- }
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement