double e = expr ();
if (Curr_tok! = RP) return error ("Rigth parentsis expected");
get_token ();
return e;
case END:
return 1;
default:
return number_value;
/* ===================== Обчислення значення функції ======================== */
double function_value ()
switch (function_number)
case 0:
return sin (expr ());
case 1:
return cos (expr ());
case 2:
return log (expr ());
case 3:
return asin (expr ());
case 4:
return acos (expr ());
case 5:
return E;
case 6:
return PI;
/* ======================== Висновок повідомлення про помилку ======================== */
double error (char * s)
int sx, sy;
char * empty_str, * Err_message;
err_message = (Char *) Malloc (strlen (s) +29);
strcpy (err_message, s);
strcat (err_message, ". Press any key to continue! "); p> empty_str = (Char *) Malloc (strlen (s) +29);
memset (empty_str, ' ', Strlen (s) +28),
empty_str [strlen (s) +28] = ' X0';
sx = Wherex ();
sy = Wherey ();
gotoxy (16,22);
textcolor (10);
cprintf ("% s", err_message);
sound (440);
delay (550);
nosound ();
getch ();
gotoxy (16,22);
cprintf ("% s", empty_str);
gotoxy (sx, sy);
textcolor (15);
free (err_message);
free (empty_str);
/* ============================== Вікно повідомлення ============= =============== */
void message ()
textcolor (RED);
gotoxy (15,21);
cprintf ("-");
for (int x = 16; x <70; x + +)
cprintf ("-");
cprintf ("-");
gotoxy (+15,22);
cprintf ("|");
gotoxy (70,22);
cprintf ("|"),
gotoxy (15,23);
cprintf ("-");
for (int x1 = 16; x1 <70; x1 + +)
cprintf ("-");
cprintf ("-"),
gotoxy (3,22);
cprintf ("Message:");
/* ================================== Рамка ========== ======================= */
void ramka ()
textcolor (10);
cprintf ("=");
for (int x = 2; x <80; x + +)
cprintf ("=");
cprintf ("=");
for (int y = 2; y <24; y + +)
cprintf ("| n b");
cprintf ("="),
for (int x1 = 2; x1 <80; x1 + +)
cprintf ("=");
cprintf ("=");
gotoxy (80,2);
for (int y1 = 2; y1 <24; y1 + +)
gotoxy (80, y1),
cprintf ("|");
/* ================================= Вікно введення ========== =================== */
void screen_input ()
textcolor (10);
gotoxy (5,3);
cprintf ("-");
for (int x = 6; x <76; x + +)
cprintf ("-");
cprintf ("-");
gotoxy (5,4);
cprintf ("|");
gotoxy (76,4);
cprintf ("|");
gotoxy (5,5);
cprintf ("-");
for (int x1 = 6; x1 <76; x1 + +)
cprintf ("-");
cprintf ("-");
textcolor (15),
gotoxy (35,2);
cprintf ("Input expression ");
/* ================================= Вікно виводу ========== =================== */
void screen_output ()
textcolor (10);
gotoxy (22,7);
cprintf ("-");
for (int x = 22; x <58; x + +)
cprintf ("-");
cprintf ("-");
gotoxy (22,8);
cprintf ("|");
gotoxy (59,8);
cprintf ("|");
gotoxy (22,9);
cprintf ("-");
for (int x1 = 22; x1 <58; x1 + +)
cprintf ("-");
cprintf ("-"),
textcolor (15),
gotoxy (39,6);
cprintf ("Answer");
/* ================================ Інформація ============ =================== */
void info ()
textcolor (10);
gotoxy (13,11);
cprintf ("Input expression, used + - */() ^ sin, cos, asin, acos, ln, pi, e ");
gotoxy (22,12);
cprintf ("Enter ; = Output answer Esc exit ");
/* ==================================== Меню ======== ======================== */
void menu (int n)
clrscr ();
textcolor (3); gotoxy (31,9);
cprintf ("Program calculator n ");
textcolor (15);
if (N == 1) textcolor (12); else
textcolor (15);
gotoxy (37,12);
cprintf ("Help n");
if (N == 2) textcolor (12); else
textcolor (15);
gotoxy (34,14);
cprintf ("Calculator n");
if (N == 3) textcolor (12); else
textcolor (15);
gotoxy (33,16);
cprintf ("About author...