Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <graphics.h>
- const int WIDTH = getmaxwidth(), HEIGHT = getmaxheight();
- void drawLine(int moveToX, int moveToY, int drawX, int drawY, int color, int textX, int textY, char *name)
- {
- moveto(moveToX, moveToY);
- setcolor(color);
- lineto(drawX, drawY);
- outtextxy(textX, textY, name);
- }
- int main()
- {
- double x, y;
- float xMin, xMax;
- printf("y = sin(x)\n");
- printf("Enter Xmin = ");
- scanf("%f", &xMin);
- printf("Enter Xmax = ");
- scanf("%f", &xMax);
- printf("Width = %d\t Height = %.d\n", WIDTH, HEIGHT);
- delay(1000);
- initwindow(WIDTH, HEIGHT);
- moveto(WIDTH / 2, HEIGHT / 2);
- drawLine(0, HEIGHT / 2, WIDTH, HEIGHT / 2, WHITE, WIDTH - 20, HEIGHT / 2 + 20, "X");
- drawLine(WIDTH / 2, 0, WIDTH / 2, HEIGHT, WHITE, WIDTH/2 + 20, 0 , "Y");
- line(WIDTH/2, 0, WIDTH/2 + 10, 20);
- line(WIDTH/2, 0, WIDTH/2 - 10, 20);
- line(WIDTH, HEIGHT/2, WIDTH-20, HEIGHT/2 - 10);
- line(WIDTH, HEIGHT/2, WIDTH-20, HEIGHT/2 + 10);
- for(x = xMin; x < xMax; x += 0.01)
- {
- y = -sin(x);
- setcolor(14);
- putpixel(WIDTH / 2 + (x * 50), HEIGHT / 2 + (y * 50), 2);
- }
- getch();
- closegraph();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement