#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#include<math.h>
void gotoxy(short x, short y)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD position = { x, y };
SetConsoleCursorPosition(handle, position);
}
void box(void)
{
int a;
for (a = 0; a <= 51; a++)//leftmost line
{
printf("%c\n", 186);
Sleep(10);
}
for (a = 0; a <= 149; a++)//uppermost line
{
Sleep(10);
gotoxy(1 + a, 0);
printf("%c", 240);
}
gotoxy(150, 0);
for (a = 0; a <= 50; a++)//correct
{
Sleep(10);
printf("%c", 186);
gotoxy(150, a + 1);
}
gotoxy(1, 51);
for (a = 0; a <= 149; a++)//Bottom line
{
Sleep(10);
printf("%c", 240);
}
}
void graph(void)
{
for (int a = 0; a <= 148; a++)
{
gotoxy(1 + a, 25);//for horizontal line
printf("_"); Sleep(10);
}
for (int a = 0; a <= 49; a++)
{
gotoxy(74, 1 + a);//for vertical line
printf("|"); Sleep(10);
}
int b = 1;
for (int a = 0; a <= 360, b <= 65; a = a + 30)//numbering
{
gotoxy(74 + b, 26); Sleep(10);
printf("%d", a);
b = b + 5;
}b = 0;
for (int a = 0; a <= 360, b <= 60; a = a + 30)//negative numbering along x aixis
{
gotoxy(74 - b, 26); Sleep(10);
printf("%d", -a);
b = b + 5;
}
gotoxy(73, 15);
printf("%d", 1); Sleep(10);
gotoxy(73, 20);
printf("%.1f", 0.5); Sleep(10);
gotoxy(73, 25); Sleep(10);
printf("%d", 0);
gotoxy(73, 35);
printf("%d", -1); Sleep(10);
gotoxy(73, 30);
printf("%.1f", -0.5); Sleep(10);
gotoxy(73, 25); Sleep(10);
printf("%d", 0);
}
void move(int l)//it will move y coordinate
{
int a;
char c[7] = { '|','/','-','\\','_','.' };
a = 1;
do {
int b;
for (b = 0; b <= 6; b++)
{
gotoxy(80, l);
printf("%c", c[b]);
Sleep(1);
}
a = a + 1;
} while (a <= 4);
}
void conbox(void)
{
int a; gotoxy(50, 0);//initial point;
Sleep(500);
for (a = 0; a <= 50; a++)//upper line
{
printf("%c", 240); Sleep(10);
gotoxy(50 + a, 0);
}
for (a = 0; a <= 50; a++)//bottom line
{
printf("%c", 240); Sleep(10);
gotoxy(50 + a, 50);
}
for (a = 0; a <= 50; a++)//left border
{
printf("%c", 186); Sleep(10);
gotoxy(50, a);
}
for (a = 0; a <= 50; a++)//left border
{
printf("%c", 186); Sleep(10);
gotoxy(100, a);
}
}
void user(void)
{
}
void main(void)
{
getch();
char op; short a1, b1, p;
char per;
short y;
float i;
do {
conbox();
gotoxy(52, 2);
printf("\"Grapher of Trignometry Functions\"");
gotoxy(52, 3);
printf("Press S for Sin function:> ");
gotoxy(80, 3);
move(3);
gotoxy(52, 4);
printf("Press C for Cos function:> ");
gotoxy(70, 4);
move(4);
gotoxy(52, 5);
printf("Press T for Tan function:> ");
gotoxy(70, 5);
move(5);
gotoxy(52, 7);//terminator
printf("\"Press \".\" to terminate\":> ");
gotoxy(60, 7);
move(7);
gotoxy(52, 9);
printf("\"Press Botton\":> ");
op = getche();
gotoxy(60, 9);
move(9);
gotoxy(60, 9);
gotoxy(60, 9);
system("cls");//cls will aslo clrea the momery
conbox();//taking amplitude and displacement
gotoxy(52, 2);
printf("\"Enter characteristics of graph\"");
gotoxy(52, 3);
printf("Amplitude :> ");
scanf("%d", &a1);
gotoxy(60, 3);
move(3);
gotoxy(60, 3);//taking amplitude
gotoxy(52, 4);
printf("Displacement :> ");
scanf("%d", &b1);
gotoxy(65, 4);
move(4);
gotoxy(65, 4);
gotoxy(52, 5);
printf("Period :>");
scanf("%d", &p); gotoxy(65, 5);
move(5); gotoxy(65, 5);
system("cls");
box();
int a;
getch();
graph();
a = 0;
if (op == 's') {
for (i = 0; i <= 360; i = i + 30)//front printing
{
float pi = 3.14;
y = a1*sin((i*(pi)*pi / 180));
gotoxy(74 + a, 25 - y);//location statement
printf("%c", 233);
Sleep(10);
a = a + 5;
}a = 0;
for (i = 0; i <= 360; i = i + 30)//back printing
{
float pi = 3.14;
y = 10 * sin((p*i*(pi) / 180));
gotoxy(74 - a, 25 + y);//location statement
printf("%c", 233);
Sleep(10);
a = a + 5;
}
}
a = 0;
if (op == 'c') {
for (i = 0; i <= 360; i = i + 30)
{
float pi = 3.14;
y = 10 * cos((i*(pi) / 180));
gotoxy(74 + a, 25 - y);
printf("%c", 233);
Sleep(50);
a = a + 5;
}a = 0;
for (i = 0; i <= 360; i = i + 30)
{
float pi = 3.14;
y = 10 * cos((i*(pi) / 180));
gotoxy(74 - a, 25 - y);
printf("%c", 233);
Sleep(50);
a = a + 5;
}
}
a = 0;
if (op == 't') {
for (i = 0; i <= 360; i = i + 30)
{
float pi = 3.14;
y = 10 * tan((i*(pi) / 180));
gotoxy(74 + a, 25 - y);
printf("%c", 233);
Sleep(1000);
a = a + 5;
}a = 0;
for (i = 0; i <= 360; i = i + 30)
{
float pi = 3.14;
y = 10 * tan((i*(pi) / 180));
gotoxy(74 - a, 25 - y);
printf(".");
Sleep(1000);
a = a + 5;
}a = 0;
}
getch();
system("cls");
printf("Enter the value");
op = getche();
system("cls");
} while (op != '.');
getche();
}
ConversionConversion EmoticonEmoticon