├── .gitignore ├── LICENSE ├── README.md └── GUICAL.c /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Nemonet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GUI Scientific Calculator 2 | (click here for more C/C++ codes) 3 | 4 | 5 | This is a C Programming Language of basic and few Advance Scientific features of Calculator. 6 | It shows a nice graphical UI of the calculator with 3D buttons and demonstrates click button animation functionality. 7 | 8 | It was developed using the Turbo C++ 3.0 IDE. 9 | It uses BGI Graphics to render all the graphics. 10 | 11 | 12 | 13 | 14 | 15 | 16 | ![images (2)](https://user-images.githubusercontent.com/79866006/171078196-0affdf6b-97c3-48db-bab1-784c7d528b12.jpeg) 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ![calculator](https://user-images.githubusercontent.com/79866006/171078232-b472673e-51d4-4f0e-b993-71e2c56fab7b.png) 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | ## The features of the calculator includes : 38 | 39 | * Basic Calculations (Add, Subtract, Multiply and Divide) 40 | 41 | * Advance Calculations (Square root, Square, Cube) 42 | 43 | * Trigonometric Functions (Sine, Cosine, Tangent, Cotangent, Secant and Cosecant) 44 | 45 | * Number Conversions (Binary, Decimal, Hexadecimal and Octal) 46 | 47 | * Logarithmic Functions (Log, Natural Log (ln), e, Exponential) 48 | 49 | * Angle Measurement (Degree, Radia and Gradian) 50 | 51 | * Other Functions (Memory, Pi and Inv) 52 | 53 | 54 | 55 | # Installation 56 | 57 | **For Windows users:** 58 | 59 | * Download and Install Turbo C++ 60 | 61 | * Open the ‛guical.c‛ file in Turbo C++ 62 | 63 | * Check out Reference 64 | 65 | 66 | **For MacOS Users:** 67 | 68 | * Download and Install Turbo C++ 69 | 70 | * Open the ‛guical.c‛ file in Turbo C++ 71 | 72 | * check out Refrence 73 | 74 | 75 | **For Linux Users:** 76 | 77 | * It kind of complicated to get it done on Linux, but once I figure a way, will drop it here. 78 | 79 | (click here for more C/C++ codes) 80 | 81 | 82 | # 🌟 🌟 🌟 83 | Pls Comment if you face any Error. 84 | And don't forget to give a Star 🌟. 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /GUICAL.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | 3 | GUI Scientific Calculator 4 | 5 | Programmer : Nemonet 6 | The Young Programmer 💻 7 | 8 | 9 | Software Details 10 | ==================== 11 | Developed in : C 12 | Compiler used : Turbo C++ 3.0 13 | Date : 20/05/2022 -- 31/05/2022 14 | 15 | Licence : MIT Licence 16 | (Please give the credit of programming to author.) 17 | 18 | 19 | NOTE: 20 | 21 | 22 | ---------------------------------------------------------------------------*/ 23 | 24 | 25 | 26 | 27 | 28 | 29 | //Please change BGI directory accouding to your TC Directory 30 | //By default it is "E:\tc\bgi" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | float * mem; 43 | int X = 0, Y = 0; 44 | int row = 17, col = 5; 45 | char dummy; 46 | char flag = 'd', flagp = '0'; 47 | char bflag = 'u', bflagp = 'u'; 48 | int mflag = 0; 49 | char ch, ch1, ch2; 50 | int sflag = 0; 51 | int midx, midy; 52 | #define UNCLICKED 0 53 | #define CLICKED 1 54 | #define PI 3.14159 55 | 56 | char str1[] = { 57 | "Nemo TYP Roll# CIS 34" 58 | }; 59 | char str2[] = { 60 | "Nemonet TYP Roll# CIS 50" 61 | }; 62 | 63 | void typeit(int x, int y, int spacing, char string[]) { 64 | char temp[2]; 65 | for (int i = 0; i < strlen(string); i++) { 66 | delay(100); 67 | temp[0] = string[i]; 68 | temp[1] = '\0'; 69 | outtextxy(x + (i + 1) * spacing, y, temp); 70 | } //endfor 71 | 72 | } 73 | void front() { 74 | int x, y, h; 75 | for (x = 0; x <= 100; x++) { 76 | settextjustify(CENTER_TEXT, CENTER_TEXT); 77 | setcolor(1); 78 | settextstyle(1, 0, 4); 79 | setusercharsize(x, 6, x, 3); 80 | setcolor(14); 81 | moveto(310, 135); 82 | outtext(".."); 83 | setcolor(6); 84 | moveto(310, 130); 85 | outtext("I I"); 86 | if (x < 50) 87 | delay(30); 88 | else 89 | delay(20); 90 | } 91 | for (y = 0; y <= 100; y++) { 92 | setcolor(0); 93 | settextstyle(1, 0, 4); 94 | setusercharsize(y, 6, y, 3); 95 | moveto(310, 135); 96 | outtext(".."); 97 | moveto(310, 130); 98 | outtext("I I"); 99 | if (y > 20) { 100 | settextstyle(7, 0, 3); 101 | setusercharsize(y - 20, 35, y - 20, 30); 102 | setcolor(9); 103 | outtext("CALCULATOR"); 104 | setcolor(2); 105 | outtext("___________"); 106 | delay(15); 107 | if (y < 100) { 108 | settextstyle(7, 0, 3); 109 | setusercharsize(y - 20, 35, y - 20, 30); 110 | setcolor(0); 111 | outtext("CALCULATOR"); 112 | } 113 | } 114 | } 115 | //delay(1000); 116 | settextstyle(3, 0, 2); 117 | delay(50); 118 | outtextxy(midx - 200, midy, "Group Members:-"); 119 | //x=10,y=10; 120 | setcolor(6); 121 | settextstyle(4, 0, 4); 122 | typeit(midx - 200, midy + 50, 15, str1); 123 | typeit(midx - 200, midy + 75, 15, str2); 124 | getch(); 125 | //closegraph(); 126 | 127 | } 128 | 129 | char input(); 130 | double add(double, double, char); 131 | double angle_conv(double); 132 | void basecng(double, double); 133 | 134 | //*********************************************************** 135 | // * 136 | // THIS FUNCTION DRAWS THE BUTTONS OF THE CALCULATOR * 137 | // * 138 | //*********************************************************** 139 | 140 | void button_3d(int x1, int y1, int x2, int y2, int check, char * text, int color) { 141 | int up, low; 142 | setfillstyle(1, 7); 143 | bar(x1, y1, x2, y2); 144 | if (check == 0) //Unclicked 145 | up = 15, low = 8; 146 | else 147 | up = 8, low = 15; //Clicked 148 | setcolor(low); 149 | line(x2, y1, x2, y2); 150 | line(x2 - 1, y1, x2 - 1, y2); 151 | line(x1, y2, x2, y2); 152 | line(x1 + 1, y2 - 1, x2, y2 - 1); 153 | 154 | setcolor(up); 155 | line(x1, y1, x2, y1); 156 | line(x1 + 1, y1 + 1, x2 - 1, y1 + 1); 157 | line(x1, y1, x1, y2); 158 | line(x1 + 1, y1 + 1, x1 + 1, y2 - 1); 159 | setcolor(color); 160 | 161 | settextjustify(CENTER_TEXT, CENTER_TEXT); 162 | outtextxy(x1 + (x2 - x1) / 2, (y1 + (y2 - y1) / 2) - 2, text); 163 | 164 | } 165 | //******************************************************************** 166 | // * 167 | // This function makes the opening screen * 168 | // * 169 | //******************************************************************** 170 | 171 | void frontpage(void) { 172 | int mx, my; 173 | 174 | mx = (getmaxx() / 2); 175 | my = (getmaxy() / 2); 176 | 177 | //SET baqckground color 178 | setfillstyle(9, 1); 179 | bar(0, 0, getmaxx(), getmaxy()); 180 | 181 | //DRAW a bar, and make it look like a 3d bar 182 | setfillstyle(1, 7); 183 | bar(50, 20, 600, 400); 184 | 185 | //DRAW lines for the top and left side 186 | setcolor(15); 187 | line(50, 20, 600, 20); 188 | line(51, 21, 599, 21); 189 | line(50, 20, 50, 400); 190 | line(51, 21, 51, 399); 191 | 192 | //DRAW lines for the bottom and right side 193 | setcolor(8); 194 | line(600, 20, 600, 400); 195 | line(599, 21, 599, 400); 196 | line(50, 400, 600, 400); 197 | line(51, 399, 600, 399); 198 | 199 | //DRAW two 3D bars for the left and right side 200 | 201 | setfillstyle(9, 8); 202 | bar(70, 40, 100, 380); 203 | //getch(); 204 | bar(545, 40, 575, 380); 205 | setcolor(8); 206 | rectangle(70, 40, 100, 380); 207 | rectangle(545, 40, 575, 380); 208 | setcolor(15); 209 | line(100, 40, 100, 380); 210 | line(70, 380, 100, 380); 211 | line(575, 40, 575, 380); 212 | line(545, 380, 575, 380); 213 | 214 | //DRAW two 3D divider lines on both sides 215 | setcolor(8); 216 | line(110, 40, 110, 380); 217 | line(535, 40, 535, 380); 218 | setcolor(15); 219 | line(111, 40, 111, 380); 220 | line(536, 40, 536, 380); 221 | 222 | //PRINT 3D text CALENDAR 223 | settextstyle(1, 0, 4); 224 | settextjustify(1, 1); 225 | setcolor(15); 226 | outtextxy(mx + 2, my - 46, "MY CALCULATOR"); 227 | setcolor(7); 228 | outtextxy(mx + 1, my - 45, "MY CALCULATOR"); 229 | setcolor(8); 230 | outtextxy(mx + 2, my - 44, "MY CALCULATOR"); 231 | 232 | //PRINT 3D text 233 | setcolor(15); 234 | outtextxy(mx, my + 10, "2022"); 235 | setcolor(7); 236 | outtextxy(mx + 1, my + 11, "2022"); 237 | setcolor(8); 238 | outtextxy(mx + 2, my + 12, "2022"); 239 | 240 | //PRINT copyright notice 241 | settextstyle(2, 0, 5); 242 | setcolor(1); 243 | outtextxy(mx + 1, my + 85, "@ 2022 by TYP 💻"); 244 | 245 | getch(); //PAUSE for a while 246 | } 247 | 248 | //******************************************************************** 249 | // * 250 | // This function makes the claculating screen * 251 | // * 252 | //******************************************************************** 253 | 254 | void screen(int x1, int y1, int x2, int y2) { 255 | setlinestyle(0, 0, 1); 256 | setfillstyle(SOLID_FILL, 8); 257 | bar(x1, y1, x2, y2); 258 | setfillstyle(SOLID_FILL, BLACK); 259 | bar(x1 + 1, y1 + 1, x2 - 1, y2 - 1); 260 | 261 | settextjustify(CENTER_TEXT, CENTER_TEXT); 262 | setcolor(15); 263 | line(x1 + 1, y1 + 1, x1 + 1, y2 - 1); 264 | line(x1 + 1, y1 + 1, x2 - 1, y1 + 1); 265 | line(x1 + 2, y1 + 2, x1 + 2, y2 - 2); 266 | line(x1 + 2, y1 + 2, x2 - 2, y1 + 2); 267 | setcolor(8); 268 | line(x1 + 1, y2 - 1, x2 - 1, y2 - 1); 269 | line(x2 - 1, y1 + 1, x2 - 1, y2 - 1); 270 | line(x1 + 2, y2 - 2, x2 - 2, y2 - 2); 271 | line(x2 - 2, y1 + 2, x2 - 2, y2 - 2); 272 | 273 | } 274 | 275 | //*********************************************************************** 276 | // * 277 | // Mouse Related Functions * 278 | // * 279 | //*********************************************************************** 280 | 281 | void init_mouse() { 282 | union REGS iregs, oregs; 283 | 284 | iregs.x.ax = 0; 285 | int86(0x33, & iregs, & oregs); 286 | 287 | if (oregs.x.ax == 0) { 288 | cleardevice(); 289 | printf("mouse not installed\n"); 290 | getch(); 291 | exit(1); 292 | } 293 | iregs.x.ax = 1; 294 | int86(0x33, & iregs, & oregs); 295 | } 296 | //************************************************************* 297 | 298 | void mouse() { 299 | int button, x1, y1; 300 | union REGS iregs, oregs; 301 | 302 | iregs.x.ax = 3; 303 | int86(0x33, & iregs, & oregs); 304 | 305 | button = oregs.x.bx & 3; 306 | x1 = oregs.x.cx; 307 | y1 = oregs.x.dx; 308 | 309 | if (oregs.x.bx & 1) { 310 | X = x1; 311 | Y = y1; 312 | } 313 | 314 | if (button == 3) 315 | exit(0); 316 | } 317 | 318 | //************************************************************* 319 | 320 | void hide_mouse() { 321 | union REGS ioRegs; 322 | ioRegs.x.ax = 2; 323 | int86(0x33, & ioRegs, & ioRegs); 324 | } 325 | 326 | //************************************************************* 327 | void show_mouse() { 328 | union REGS ioRegs; 329 | ioRegs.x.ax = 1; 330 | int86(0x33, & ioRegs, & ioRegs); 331 | } 332 | 333 | /*************************************************************/void remove_mouse() { 334 | union REGS ioRegs; 335 | ioRegs.x.ax = 0; 336 | int86(0x33, & ioRegs, & ioRegs); 337 | } 338 | 339 | //************************************************************************ 340 | // * 341 | // THIS FUNCTION DRAWS THE CALCULATOR ON THE SCREEN * 342 | // * 343 | //************************************************************************ 344 | void structure() { 345 | init_mouse(); 346 | setbkcolor(0); 347 | cleardevice(); 348 | hide_mouse(); 349 | //********************************************************** 350 | // Buttons Making 351 | 352 | front(); 353 | frontpage(); 354 | settextstyle(2, 0, 4); 355 | button_3d(50, 20, 600, 400, UNCLICKED, "", 1); // main box 356 | screen(100, 50, 545, 120); // screen 357 | 358 | setfillstyle(1, 8); 359 | bar(52, 22, 598, 42); 360 | button_3d(575, 23, 595, 40, UNCLICKED, "x", 0); 361 | setcolor(0); 362 | outtextxy(120, 30, "CALCULATOR v1.0"); 363 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 15); // box of decimal 364 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 0); // box of octal 365 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 0); // box of hexal 366 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 0); // box of binary 367 | 368 | button_3d(350, 205, 380, 225, UNCLICKED, "7", 0); // Box Of 7 369 | button_3d(390, 205, 420, 225, UNCLICKED, "8", 0); // Box Of 8 370 | button_3d(430, 205, 460, 225, UNCLICKED, "9", 0); // Box Of 9 371 | 372 | button_3d(350, 230, 380, 250, UNCLICKED, "4", 0); // Box Of 4 373 | button_3d(390, 230, 420, 250, UNCLICKED, "5", 0); // Box Of 5 374 | button_3d(430, 230, 460, 250, UNCLICKED, "6", 0); // Box Of 6 375 | 376 | button_3d(480, 230, 510, 250, UNCLICKED, "*", 0); // Box Of * 377 | button_3d(515, 230, 545, 250, UNCLICKED, "/", 0); // Box Of \ 378 | button_3d(480, 205, 510, 225, UNCLICKED, "AC", 4); //Box Of AllClear (AC) 379 | button_3d(515, 205, 545, 225, UNCLICKED, "CE", 4); //Box Of Clear (C) 380 | 381 | button_3d(350, 255, 380, 275, UNCLICKED, "1", 0); // Box Of 1 382 | button_3d(390, 255, 420, 275, UNCLICKED, "2", 0); // Box Of 2 383 | button_3d(430, 255, 460, 275, UNCLICKED, "3", 0); // Box Of 3 384 | 385 | button_3d(350, 280, 380, 300, UNCLICKED, "0", 0); // Box Of Zero (0) 386 | button_3d(390, 280, 420, 300, UNCLICKED, ".", 0); // Box Of Period (.) 387 | button_3d(430, 280, 460, 300, UNCLICKED, "pi", 0); // Box Of PhiFunction 388 | 389 | button_3d(480, 255, 510, 275, UNCLICKED, "-", 0); // Box Of - 390 | button_3d(515, 255, 545, 275, UNCLICKED, "+", 0); // Box Of + 391 | button_3d(350, 305, 460, 325, UNCLICKED, "=", 0); // Box Of Equality 392 | button_3d(480, 305, 545, 325, UNCLICKED, "shift", BLUE); // Box Of shift 393 | 394 | button_3d(480, 280, 510, 300, UNCLICKED, "sqrt", 0); //Box of x^n 395 | button_3d(515, 280, 545, 300, UNCLICKED, "inv", 0); //box of 1/x 396 | 397 | button_3d(100, 205, 150, 230, UNCLICKED, "Sin", 0); // Box OfSin Function 398 | button_3d(160, 205, 210, 230, UNCLICKED, "Cos", 0); // Box Of CosFunction 399 | button_3d(220, 205, 270, 230, UNCLICKED, "Tan", 0); // Box Of Tan Function 400 | 401 | button_3d(100, 250, 150, 275, UNCLICKED, "sin^-1", 0); // Box Of sin^-1 402 | button_3d(160, 250, 210, 275, UNCLICKED, "cos^-1", 0); // Box Of cos^-1 403 | button_3d(220, 250, 270, 275, UNCLICKED, "tan^-1", 0); // Box Of tan^-1 404 | 405 | button_3d(100, 300, 150, 325, UNCLICKED, "ln", 0); // Box Of ln 406 | settextjustify(CENTER_TEXT, CENTER_TEXT); 407 | setcolor(BLUE); 408 | settextstyle(2, 0, 4); 409 | outtextxy(125, 290, "e"); 410 | outtextxy(185, 290, "10^x"); 411 | outtextxy(245, 290, "x^3"); 412 | button_3d(160, 300, 210, 325, UNCLICKED, "log", 0); // Box Of log 413 | button_3d(220, 300, 270, 325, UNCLICKED, "x^2", 0); // Box Of x^2 414 | 415 | button_3d(100, 350, 150, 370, UNCLICKED, "deg", 15); 416 | button_3d(160, 350, 210, 370, UNCLICKED, "rad", 0); 417 | button_3d(220, 350, 270, 370, UNCLICKED, "gra", 0); 418 | button_3d(480, 350, 545, 370, UNCLICKED, "Off", 4); 419 | 420 | button_3d(350, 350, 380, 370, UNCLICKED, "M+", 0); 421 | button_3d(390, 350, 420, 370, UNCLICKED, "M-", 0); 422 | button_3d(430, 350, 460, 370, UNCLICKED, "MR", 0); 423 | 424 | } 425 | //******************************************************** 426 | // * 427 | // Main starts * 428 | // * 429 | //******************************************************** 430 | void main() { 431 | clrscr(); 432 | 433 | double y = 0, z = 0, pnt, pnt1 = 0, x = 0, r = 0; 434 | 435 | int gdriver = DETECT, gmode, errorcode; 436 | int i; 437 | initgraph( & gdriver, & gmode, "C:\\TURBOC3\\BGI"); 438 | midx = getmaxx() / 2; 439 | midy = getmaxy() / 2; 440 | structure(); 441 | gotoxy(row, col); 442 | printf("\t\t\t\t\t"); 443 | gotoxy(row, col); 444 | printf("0"); 445 | mem = (float * ) malloc(y * sizeof(float)); 446 | while (ch != 27 && ch1 != 27) //While Escape is not pressed 447 | { //and if base is not 10 448 | pnt1 = 0; //no doubleing point entered Yet 449 | ch2 = '0'; 450 | // for(int a=0;ch!=27;a++)//a indicates whether a no. has been entered or not 451 | while (ch2 != 27) 452 | //a=0 means that no no. has been entered yet 453 | { 454 | if (bflagp != 'u') { 455 | //gotoxy(row,col); 456 | dummy = input(); 457 | if (dummy != 'o') { 458 | gotoxy(row, col); 459 | printf("The trail version does not support this feature"); 460 | input(); 461 | gotoxy(row, col); 462 | printf("\t\t\t\t\t\t"); 463 | // ch='0'; 464 | } 465 | y = 0; 466 | z = 0; 467 | ch = '0'; 468 | gotoxy(row, col); 469 | printf("\t\t\t\t\t\t"); 470 | gotoxy(row, col); 471 | printf("0"); 472 | 473 | // bflagp='u'; 474 | } 475 | 476 | ch = input(); 477 | if (ch == '>' || ch == '<' || ch == '?') { 478 | sflag = 0; 479 | if (ch == '>') //M+ 480 | * 481 | mem += y; 482 | if (ch == '<') //M- 483 | * 484 | mem -= y; 485 | if (ch == '?') //MR 486 | { 487 | y = * mem; 488 | gotoxy(row, col); 489 | printf("\t\t\t\t\t\t"); 490 | gotoxy(row, col); 491 | printf("%g", y); 492 | } 493 | if ( * mem == 0) 494 | mflag = 0; 495 | if ( * mem != 0) 496 | mflag = 1; 497 | } 498 | if (mflag == 0) { 499 | gotoxy(row, 7); 500 | 501 | printf(" "); 502 | 503 | } 504 | if (mflag != 0) { 505 | gotoxy(row, 7); 506 | 507 | printf("M"); 508 | } 509 | gotoxy(row, col); 510 | 511 | if (ch == 'a') { 512 | sflag = 0; 513 | y = 0; 514 | gotoxy(row, col); 515 | printf("\t\t\t\t\t"); 516 | gotoxy(row, col); 517 | printf("0"); 518 | } 519 | 520 | if (ch == 'o') 521 | //for clearing the screen of the CALCULATOR 522 | { 523 | sflag = 0; 524 | y = 0; 525 | z = 0; 526 | gotoxy(row, col); 527 | printf("\t\t\t\t "); 528 | gotoxy(row, col); 529 | printf("0"); 530 | gotoxy(row, col); 531 | break; 532 | } 533 | 534 | if (ch == 'q') { 535 | sflag = 0; 536 | y = sqrt(y); 537 | gotoxy(row, col); 538 | printf("\t\t\t\t "); 539 | gotoxy(row, col); 540 | printf("%g", y); 541 | } 542 | if (ch == 'm') { 543 | sflag = 0; 544 | y = 1 / y; 545 | gotoxy(row, col); 546 | printf("\t\t\t\t "); 547 | gotoxy(row, col); 548 | printf("%g", y); 549 | } 550 | if (ch == '+' || ch == '-' || ch == '/' || ch == '\\' || ch == '=' || ch == '*') { 551 | sflag = 0; 552 | break; 553 | } 554 | if (ch == '.') //case for a decimal point 555 | { 556 | sflag = 0; 557 | if (pnt1 == 0) //ie no decimal has been entered yet 558 | { 559 | gotoxy(row, col); 560 | printf("\t\t\t\t "); // double 561 | gotoxy(row, col); 562 | printf("%g.", y); 563 | pnt1 = .1; //ie one decimal point no has been entered 564 | continue; //go back to the begining and get the next number 565 | } else //decimal point has alredy been entered and thus no change in the screen 566 | { 567 | sflag = 0; 568 | continue; //go back to the begining 569 | } 570 | } //out of the '.' condition 571 | 572 | if (pnt1 != 0) //ie we have a doubleing point 573 | { 574 | sflag = 0; 575 | if (ch <= '9' && ch >= '0') //input integer 576 | { 577 | // printf("%c",ch); 578 | x = (double) ch; //type cast the character into double to perforn further operations 579 | x -= 48; //since character digit indoubleing -48 gives the corresponding ASCII 580 | x = x * pnt1; //make it a decimal 581 | y = x + y; //add it in result 582 | pnt1 *= .1; //shift to the second doubleing point 583 | gotoxy(row, col); 584 | printf("%g", y); 585 | gotoxy(row, col); 586 | continue; //back to the top 587 | } 588 | } 589 | //if no decimal point number then proceed 590 | 591 | if (ch <= '9' && ch >= '0') { 592 | sflag = 0; 593 | x = (double) ch; //typecast to double 594 | x -= 48; //get corresponding ASCII 595 | y = (y * 10) + x; //add to right of result 596 | gotoxy(row, col); //go back to start of the calc screen 597 | printf("\t\t\t\t "); //clear the screen 598 | gotoxy(row, col); 599 | printf("%g", y); //print the number 600 | } 601 | if (ch == 'u' || ch == 'v' || ch == 'w' || ch == 'x') { 602 | sflag = 0; 603 | if (bflagp == bflag && bflag == 'u') 604 | continue; 605 | else 606 | basecng(y, pnt1); 607 | } 608 | if (ch == 'd' || ch == 'r' || ch == 'g') { 609 | sflag = 0; 610 | y = angle_conv(y); 611 | gotoxy(row, col); 612 | printf("\t\t\t\t "); 613 | gotoxy(row, col); 614 | printf("%g", y); 615 | // gotoxy(row,col); 616 | // printf("%g",y); 617 | // continue; 618 | } 619 | if (ch == 's' || ch == 'c' || ch == 't' || ch == 'i' || ch == 'j' || ch == 'k' || ch == 'n' || ch == 'l' || ch == 'p' || ch == 'h') 620 | //ie the user opted for a function 621 | { 622 | if (ch == 's' || ch == 'c' || ch == 't') //sin /cos/tan 623 | { 624 | sflag = 0; 625 | if (flag != 'r') { 626 | flagp = flag; 627 | flag = 'r'; 628 | y = angle_conv(y); 629 | flag = flagp; 630 | } 631 | // gotoxy(row,col); 632 | // printf("%g",y);getch(); 633 | switch (ch) { 634 | 635 | case 's': 636 | y = sin(y); 637 | break; 638 | case 'c': 639 | y = cos(y); 640 | break; 641 | case 't': 642 | y = tan(y); 643 | break; 644 | } 645 | } 646 | if (ch == 'i' || ch == 'j' || ch == 'k') { 647 | sflag = 0; 648 | if (flag != 'r') { 649 | // flagp=flag; 650 | flagp = 'r'; 651 | //y=angle_conv(y); 652 | } 653 | switch (ch) { 654 | case 'i': 655 | y = asin(y); 656 | break; 657 | case 'j': 658 | y = acos(y); 659 | break; 660 | case 'k': 661 | y = atan(y); 662 | break; 663 | } 664 | if (flag != 'r') 665 | y = angle_conv(y); 666 | } else if (ch == 'n') { 667 | if (sflag == 1) { 668 | y = exp(y); 669 | sflag = 0; 670 | } else 671 | y = log(y); //ln 672 | } else if (ch == 'l') { 673 | if (sflag == 1) { 674 | y = pow(10, y); 675 | sflag = 0; 676 | } else 677 | y = log10(y); //log 678 | } else if (ch == 'p') { 679 | if (sflag == 1) { 680 | y = pow(y, 3); 681 | sflag = 0; 682 | } else 683 | y = pow(y, 2); //square 684 | } else if (ch == 'h') { 685 | sflag = 0; 686 | y = PI; //pi 687 | } 688 | 689 | gotoxy(row, col); 690 | printf("\t\t\t\t "); //Clear the screen 691 | gotoxy(row, col); 692 | printf("%g", y); 693 | } //else condition 694 | 695 | } //out of second condition ie we now have the first no. or function or operater 696 | 697 | for (; ch != 27 && ch1 != '=' && ch != '=';) //ie the characters input are not ESCAPE or Equal to 698 | 699 | { 700 | pnt1 = 0; 701 | z = 0; 702 | if (ch == 'o' || ch1 == 'o') // For Clear The Screen 703 | { 704 | 705 | sflag = 0; 706 | y = 0; 707 | z = 0; 708 | gotoxy(row, col); 709 | printf("\t\t\t\t "); 710 | // gotoxy(col,row); 711 | gotoxy(row, col); 712 | printf("0"); 713 | gotoxy(row, col); 714 | break; 715 | } 716 | for (; ch1 != 27;) { 717 | gotoxy(row, col); 718 | // printf("%g",z); 719 | // z=0; 720 | ch1 = input(); 721 | 722 | if (ch1 == '>' || ch1 == '<' || ch1 == '?') { 723 | if (ch1 == '>') //M+ 724 | * 725 | mem += z; 726 | if (ch1 == '<') //M- 727 | * 728 | mem -= z; 729 | if (ch1 == '?') //MR 730 | { 731 | z = * mem; 732 | gotoxy(row, col); 733 | printf("\t\t\t\t "); 734 | gotoxy(row, col); 735 | printf("%g", z); 736 | } 737 | if ( * mem == 0) 738 | mflag = 0; 739 | if ( * mem != 0) 740 | mflag = 1; 741 | } 742 | if (mflag == 0) { 743 | gotoxy(row, 7); 744 | printf(" "); 745 | } 746 | if (mflag != 0) { 747 | gotoxy(row, 7); 748 | printf("M"); 749 | } 750 | gotoxy(row, col); 751 | 752 | if (ch1 == 'a') { 753 | z = 0; 754 | gotoxy(row, col); 755 | printf("\t\t\t\t "); 756 | gotoxy(row, col); 757 | printf("0"); 758 | } 759 | 760 | if (ch == 'o' || ch1 == 'o') // For Clear The Screen 761 | { 762 | y = 0; 763 | z = 0; 764 | gotoxy(row, col); 765 | //cout<<" "; 766 | printf("\t\t\t\t "); 767 | gotoxy(row, col); 768 | printf("0"); 769 | gotoxy(row, col); 770 | break; 771 | } 772 | if (ch1 == 'q') { 773 | z = sqrt(z); 774 | gotoxy(row, col); 775 | printf("\t\t\t\t "); 776 | gotoxy(row, col); 777 | printf("%g", z); 778 | } 779 | if (ch1 == 'm') { 780 | z = 1 / z; 781 | gotoxy(row, col); 782 | printf("\t\t\t\t "); 783 | gotoxy(row, col); 784 | printf("%g", z); 785 | } 786 | 787 | if (ch1 == '.') { 788 | if (pnt1 == 0) { 789 | gotoxy(row, col); 790 | printf("\t\t\t\t "); 791 | gotoxy(row, col); 792 | //cout<= '0') { 802 | // printf("%c",ch1); 803 | x = (double) ch1; 804 | x -= 48; 805 | x = x * pnt1; 806 | z = x + z; 807 | pnt1 = pnt1 * .1; 808 | gotoxy(row, col); 809 | printf("\t\t\t\t "); 810 | gotoxy(row, col); 811 | printf("%g", z); 812 | continue; 813 | } 814 | } 815 | 816 | if (ch1 == '+' || ch1 == '-' || ch1 == '*' || ch1 == '/' || ch1 == '=') 817 | break; 818 | if (ch1 >= '0' && ch1 <= '9') { 819 | x = (double) ch1; 820 | x = x - 48; 821 | gotoxy(row, col); 822 | printf("\t\t\t\t "); 823 | gotoxy(row, col); 824 | z = (z * 10) + x; 825 | printf("%g", z); 826 | } 827 | if (ch == 'u') 828 | if (ch == 'd' || ch == 'r' || ch == 'g') { 829 | z = angle_conv(z); 830 | gotoxy(row, col); 831 | printf("\t\t\t\t "); 832 | gotoxy(row, col); 833 | printf("%g", z); 834 | // continue; 835 | } 836 | if (ch1 == 's' || ch1 == 'c' || ch1 == 't' || ch1 == 'i' || ch1 == 'j' || ch1 == 'k' || ch1 == 'n' || ch1 == 'l' || ch1 == 'p' || ch1 == 'h') 837 | //ie the user opted for a function 838 | { 839 | if (ch1 == 's' || ch1 == 'c' || ch1 == 't') //sin 840 | { 841 | if (flag != 'r') { 842 | flagp = flag; 843 | flag = 'r'; 844 | angle_conv(z); 845 | flag = flagp; 846 | } 847 | switch (ch1) { 848 | case 's': 849 | z = sin(z); 850 | break; 851 | case 'c': 852 | z = cos(z); 853 | break; 854 | case 't': 855 | z = tan(z); 856 | break; 857 | } 858 | } 859 | if (ch1 == 'i' || ch1 == 'j' || ch1 == 'k') { 860 | if (flag != 'r') { 861 | flagp = 'r'; 862 | } 863 | switch (ch1) { 864 | case 'i': 865 | z = asin(z); 866 | break; 867 | case 'j': 868 | z = acos(z); 869 | break; 870 | case 'k': 871 | z = atan(z); 872 | break; 873 | } 874 | z = angle_conv(z); 875 | } else if (ch1 == 'l') { 876 | z = log10(z); //log 877 | } else if (ch1 == 'p') { 878 | z = pow(z, 2); //square 879 | } else if (ch1 == 'h') { 880 | z = PI; //pi 881 | } 882 | 883 | gotoxy(row, col); 884 | printf("\t\t\t\t "); 885 | gotoxy(row, col); 886 | printf("%g", z); 887 | gotoxy(row, col); 888 | } 889 | } 890 | 891 | if (ch1 == '+' || ch1 == '-' || ch1 == '=') { 892 | y = add(y, z, ch); 893 | if (ch2 != '0') { 894 | y = add(r, y, ch2); 895 | ch2 = '0'; 896 | } 897 | } else { 898 | if (ch == '*' || ch == '/') 899 | y = add(y, z, ch); 900 | else { 901 | ch2 = ch; 902 | r = y; 903 | y = z; 904 | } 905 | } 906 | gotoxy(row, col); 907 | printf("\t\t\t\t "); 908 | gotoxy(row, col); 909 | printf("%g", y); 910 | ch = ch1; 911 | ch1 = '0'; 912 | if (ch == '=' || ch1 == '=') 913 | break; 914 | } 915 | if (ch == 'o' || ch1 == 'o') // For Clear The Screen 916 | { 917 | y = 0; 918 | z = 0; 919 | gotoxy(row, col); 920 | printf("\t\t\t\t "); 921 | gotoxy(row, col); 922 | printf("0"); 923 | gotoxy(row, col); 924 | continue; 925 | } 926 | gotoxy(row, col); 927 | printf("\t\t\t\t "); 928 | gotoxy(row, col); 929 | printf("%g", y); 930 | z = 0; 931 | } 932 | 933 | // getch(); 934 | closegraph(); 935 | remove_mouse(); 936 | exit(0); 937 | 938 | } 939 | 940 | //************************************************************ 941 | // * 942 | // This function gets the user's Input * 943 | // * 944 | //************************************************************ 945 | 946 | char input() { 947 | X = 0; 948 | Y = 0; 949 | char ch; 950 | show_mouse(); 951 | if (bflag != 'u') { 952 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 15); 953 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 0); 954 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 0); 955 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 0); 956 | bflag = 'u'; 957 | } 958 | do { 959 | mouse(); 960 | if (X >= 350 && X <= 380 && Y >= 205 && Y <= 225) // Condition For 7 961 | { 962 | hide_mouse(); 963 | button_3d(350, 205, 380, 225, CLICKED, "7", 0); 964 | show_mouse(); 965 | delay(250); 966 | hide_mouse(); 967 | button_3d(350, 205, 380, 225, UNCLICKED, "7", 0); 968 | show_mouse(); 969 | ch = '7'; 970 | return ch; 971 | } 972 | 973 | //********************************************** 974 | 975 | if (X >= 390 && X <= 420 && Y >= 205 && Y <= 225) // Condition For 8 976 | { 977 | 978 | hide_mouse(); 979 | button_3d(390, 205, 420, 225, CLICKED, "8", 0); 980 | show_mouse(); 981 | delay(250); 982 | hide_mouse(); 983 | button_3d(390, 205, 420, 225, UNCLICKED, "8", 0); 984 | show_mouse(); 985 | ch = '8'; 986 | return ch; 987 | } 988 | 989 | //***************************************** 990 | 991 | if (X >= 430 && X <= 460 && Y >= 205 && Y <= 225) // Condition For 9 992 | { 993 | hide_mouse(); 994 | button_3d(430, 205, 460, 225, CLICKED, "9", 0); 995 | show_mouse(); 996 | delay(250); 997 | hide_mouse(); 998 | button_3d(430, 205, 460, 225, UNCLICKED, "9", 0); 999 | show_mouse(); 1000 | ch = '9'; 1001 | return ch; 1002 | } 1003 | 1004 | //*********************************** 1005 | 1006 | if (X >= 350 && X <= 380 && Y >= 230 && Y <= 250) // Condition For 4 1007 | { 1008 | hide_mouse(); 1009 | button_3d(350, 230, 380, 250, CLICKED, "4", 0); 1010 | show_mouse(); 1011 | delay(250); 1012 | hide_mouse(); 1013 | button_3d(350, 230, 380, 250, UNCLICKED, "4", 0); 1014 | show_mouse(); 1015 | ch = '4'; 1016 | return ch; 1017 | } 1018 | 1019 | //*********************************** 1020 | 1021 | if (X >= 390 && X <= 420 && Y >= 230 && Y <= 250) // Condition For 5 1022 | { 1023 | hide_mouse(); 1024 | button_3d(390, 230, 420, 250, CLICKED, "5", 0); 1025 | show_mouse(); 1026 | delay(250); 1027 | hide_mouse(); 1028 | button_3d(390, 230, 420, 250, UNCLICKED, "5", 0); 1029 | show_mouse(); 1030 | ch = '5'; 1031 | return ch; 1032 | } 1033 | 1034 | //*********************************** 1035 | 1036 | if (X >= 430 && X <= 460 && Y >= 230 && Y <= 250) // Condition For 6 1037 | { 1038 | hide_mouse(); 1039 | button_3d(430, 230, 460, 250, CLICKED, "6", 0); 1040 | show_mouse(); 1041 | delay(250); 1042 | hide_mouse(); 1043 | button_3d(430, 230, 460, 250, UNCLICKED, "6", 0); 1044 | show_mouse(); 1045 | ch = '6'; 1046 | return ch; 1047 | } 1048 | 1049 | //*********************************** 1050 | 1051 | if (X >= 480 && X <= 510 && Y >= 230 && Y <= 250) // Condition For * 1052 | { 1053 | hide_mouse(); 1054 | button_3d(480, 230, 510, 250, CLICKED, "*", 0); 1055 | show_mouse(); 1056 | delay(250); 1057 | hide_mouse(); 1058 | button_3d(480, 230, 510, 250, UNCLICKED, "*", 0); 1059 | show_mouse(); 1060 | ch = '*'; 1061 | return ch; 1062 | } 1063 | //*********************************** 1064 | 1065 | if (X >= 515 && X <= 545 && Y >= 230 && Y <= 250) // Condition For / 1066 | { 1067 | hide_mouse(); 1068 | button_3d(515, 230, 545, 250, CLICKED, "/", 0); 1069 | show_mouse(); 1070 | delay(250); 1071 | hide_mouse(); 1072 | button_3d(515, 230, 545, 250, UNCLICKED, "/", 0); 1073 | show_mouse(); 1074 | ch = '/'; 1075 | return ch; 1076 | } 1077 | 1078 | //*********************************** 1079 | int a, b; 1080 | if (X >= 350 && X <= 380 && Y >= 255 && Y <= 275) // Condition For 1 1081 | { 1082 | hide_mouse(); 1083 | button_3d(350, 255, 380, 275, CLICKED, "1", 0); 1084 | show_mouse(); 1085 | delay(250); 1086 | hide_mouse(); 1087 | button_3d(350, 255, 380, 275, UNCLICKED, "1", 0); 1088 | show_mouse(); 1089 | ch = '1'; 1090 | return ch; 1091 | } 1092 | 1093 | // ************************************* 1094 | 1095 | if (X >= 390 && X <= 420 && Y >= 255 && Y <= 275) // Condition For 2 1096 | { 1097 | hide_mouse(); 1098 | button_3d(390, 255, 420, 275, CLICKED, "2", 0); 1099 | show_mouse(); 1100 | delay(250); 1101 | hide_mouse(); 1102 | button_3d(390, 255, 420, 275, UNCLICKED, "2", 0); 1103 | show_mouse(); 1104 | ch = '2'; 1105 | return ch; 1106 | } 1107 | 1108 | // ************************************* 1109 | 1110 | if (X >= 430 && X <= 460 && Y >= 255 && Y <= 275) // Condition For 3 1111 | { 1112 | hide_mouse(); 1113 | button_3d(430, 255, 460, 275, CLICKED, "3", 0); 1114 | show_mouse(); 1115 | delay(250); 1116 | hide_mouse(); 1117 | button_3d(430, 255, 460, 275, UNCLICKED, "3", 0); 1118 | show_mouse(); 1119 | ch = '3'; 1120 | return ch; 1121 | } 1122 | 1123 | // ************************************* 1124 | 1125 | if (X >= 350 && X <= 380 && Y >= 280 && Y <= 300) // Condition For 0 1126 | { 1127 | hide_mouse(); 1128 | button_3d(350, 280, 380, 300, CLICKED, "0", 0); 1129 | show_mouse(); 1130 | delay(250); 1131 | hide_mouse(); 1132 | button_3d(350, 280, 380, 300, UNCLICKED, "0", 0); 1133 | show_mouse(); 1134 | ch = '0'; 1135 | return ch; 1136 | } 1137 | 1138 | // ************************************* 1139 | 1140 | if (X >= 390 && X <= 420 && Y >= 280 && Y <= 300) // Condition For . 1141 | { 1142 | hide_mouse(); 1143 | button_3d(390, 280, 420, 300, CLICKED, ".", 0); 1144 | show_mouse(); 1145 | delay(250); 1146 | hide_mouse(); 1147 | button_3d(390, 280, 420, 300, UNCLICKED, ".", 0); 1148 | show_mouse(); 1149 | ch = '.'; 1150 | return ch; 1151 | } 1152 | 1153 | //********************************************** 1154 | 1155 | if (X >= 430 && X <= 460 && Y >= 280 && Y <= 300) // Condition For pi 1156 | { 1157 | hide_mouse(); 1158 | button_3d(430, 280, 460, 300, CLICKED, "pi", 0); 1159 | show_mouse(); 1160 | delay(250); 1161 | hide_mouse(); 1162 | button_3d(430, 280, 460, 300, UNCLICKED, "pi", 0); 1163 | show_mouse(); 1164 | ch = 'h'; 1165 | return ch; 1166 | } 1167 | 1168 | //*********************************************** 1169 | 1170 | if (X >= 480 && X <= 510 && Y >= 255 && Y <= 275) // Condition For - 1171 | { 1172 | hide_mouse(); 1173 | button_3d(480, 255, 510, 275, CLICKED, "-", 0); 1174 | show_mouse(); 1175 | delay(250); 1176 | hide_mouse(); 1177 | button_3d(480, 255, 510, 275, UNCLICKED, "-", 0); 1178 | show_mouse(); 1179 | ch = '-'; 1180 | return ch; 1181 | } 1182 | 1183 | //************************************************** 1184 | 1185 | if (X >= 515 && X <= 545 && Y >= 255 && Y <= 275) // Condition For + 1186 | { 1187 | hide_mouse(); 1188 | button_3d(515, 255, 545, 275, CLICKED, "+", 0); 1189 | show_mouse(); 1190 | delay(250); 1191 | hide_mouse(); 1192 | button_3d(515, 255, 545, 275, UNCLICKED, "+", 0); 1193 | show_mouse(); 1194 | ch = '+'; 1195 | return ch; 1196 | } 1197 | 1198 | //***************************************************** 1199 | 1200 | if (X >= 350 && X <= 460 && Y >= 305 && Y <= 325) // Condition For = 1201 | { 1202 | hide_mouse(); 1203 | button_3d(350, 305, 460, 325, CLICKED, "=", 0); 1204 | show_mouse(); 1205 | delay(250); 1206 | hide_mouse(); 1207 | button_3d(350, 305, 460, 325, UNCLICKED, "=", 0); 1208 | show_mouse(); 1209 | ch = '='; 1210 | return ch; 1211 | } 1212 | 1213 | //***************************************************** 1214 | 1215 | if (X >= 480 && X <= 545 && Y >= 305 && Y <= 325) // Condition For shift 1216 | { 1217 | hide_mouse(); 1218 | button_3d(480, 305, 545, 325, CLICKED, "shift", BLUE); 1219 | show_mouse(); 1220 | delay(250); 1221 | hide_mouse(); 1222 | button_3d(480, 305, 545, 325, UNCLICKED, "shift", BLUE); 1223 | show_mouse(); 1224 | ch = '~'; 1225 | sflag = 1; 1226 | return ch; 1227 | } 1228 | 1229 | //************************************* 1230 | 1231 | if (X >= 480 && X <= 510 && Y >= 205 && Y <= 225) // Condition For AC 1232 | { 1233 | hide_mouse(); 1234 | button_3d(480, 205, 510, 225, CLICKED, "AC", 4); 1235 | show_mouse(); 1236 | delay(250); 1237 | hide_mouse(); 1238 | button_3d(480, 205, 510, 225, UNCLICKED, "AC", 4); 1239 | show_mouse(); 1240 | ch = 'o'; 1241 | return ch; 1242 | } 1243 | /********************C*/ if (X >= 515 && X <= 545 && Y >= 205 && Y <= 225) // Condition For C 1244 | { 1245 | hide_mouse(); 1246 | button_3d(515, 205, 545, 225, CLICKED, "CE", 4); 1247 | show_mouse(); 1248 | delay(250); 1249 | hide_mouse(); 1250 | button_3d(515, 205, 545, 225, UNCLICKED, "CE", 4); 1251 | show_mouse(); 1252 | ch = 'a'; 1253 | return ch; 1254 | } 1255 | 1256 | // **************************************** 1257 | 1258 | if (X >= 100 && X <= 150 && Y >= 205 && Y <= 230) // Condition For Sin 1259 | { 1260 | hide_mouse(); 1261 | button_3d(100, 205, 150, 230, CLICKED, "Sin", 0); 1262 | show_mouse(); 1263 | delay(250); 1264 | hide_mouse(); 1265 | button_3d(100, 205, 150, 230, UNCLICKED, "Sin", 0); 1266 | show_mouse(); 1267 | ch = 's'; 1268 | return ch; 1269 | } 1270 | 1271 | //*********************************** 1272 | 1273 | if (X >= 160 && X <= 210 && Y >= 205 && Y <= 230) // Condition For Cos 1274 | { 1275 | hide_mouse(); 1276 | button_3d(160, 205, 210, 230, CLICKED, "Cos", 0); 1277 | show_mouse(); 1278 | delay(250); 1279 | hide_mouse(); 1280 | button_3d(160, 205, 210, 230, UNCLICKED, "Cos", 0); 1281 | show_mouse(); 1282 | ch = 'c'; 1283 | return ch; 1284 | } 1285 | 1286 | //*********************************** 1287 | 1288 | if (X >= 515 && X <= 545 && Y >= 280 && Y <= 300) //inverse 1289 | { 1290 | hide_mouse(); 1291 | button_3d(515, 280, 545, 300, CLICKED, "inv", 0); 1292 | show_mouse(); 1293 | delay(250); 1294 | hide_mouse(); 1295 | button_3d(515, 280, 545, 300, UNCLICKED, "inv", 0); 1296 | show_mouse(); 1297 | ch = 'm'; 1298 | return ch; 1299 | } 1300 | 1301 | if (X >= 220 && X <= 270 && Y >= 205 && Y <= 230) // Condition For Tan 1302 | { 1303 | hide_mouse(); 1304 | button_3d(220, 205, 270, 230, CLICKED, "Tan", 0); 1305 | show_mouse(); 1306 | delay(250); 1307 | hide_mouse(); 1308 | button_3d(220, 205, 270, 230, UNCLICKED, "Tan", 0); 1309 | show_mouse(); 1310 | ch = 't'; 1311 | return ch; 1312 | } 1313 | 1314 | //*********************************** */ 1315 | if (X >= 100 && X <= 150 && Y >= 250 && Y <= 275) // Condition For sin^-1 1316 | { 1317 | hide_mouse(); 1318 | button_3d(100, 250, 150, 275, CLICKED, "sin^-1", 0); 1319 | show_mouse(); 1320 | delay(150); 1321 | hide_mouse(); 1322 | button_3d(100, 250, 150, 275, UNCLICKED, "sin^-1", 0); 1323 | show_mouse(); 1324 | ch = 'i'; 1325 | return ch; 1326 | } 1327 | //************************** 1328 | 1329 | if (X >= 160 && X <= 210 && Y >= 250 && Y <= 275) // Condition For cos^-1 1330 | { 1331 | hide_mouse(); 1332 | button_3d(160, 250, 210, 275, CLICKED, "cos^-1", 0); 1333 | show_mouse(); 1334 | delay(250); 1335 | hide_mouse(); 1336 | button_3d(160, 250, 210, 275, UNCLICKED, "cos^-1", 0); 1337 | show_mouse(); 1338 | ch = 'j'; 1339 | return ch; 1340 | } 1341 | //************************** 1342 | 1343 | if (X >= 430 && X <= 460 && Y >= 350 && Y <= 370) // Condition For MR 1344 | { 1345 | hide_mouse(); 1346 | button_3d(430, 350, 460, 370, CLICKED, "MR", 0); 1347 | show_mouse(); 1348 | delay(250); 1349 | hide_mouse(); 1350 | button_3d(430, 350, 460, 370, UNCLICKED, "MR", 0); 1351 | show_mouse(); 1352 | ch = '?'; 1353 | return ch; 1354 | } 1355 | if (X >= 390 && X <= 420 && Y >= 350 && Y <= 370) // Condition For M- 1356 | { 1357 | hide_mouse(); 1358 | button_3d(390, 350, 420, 370, CLICKED, "M-", 0); 1359 | show_mouse(); 1360 | delay(250); 1361 | hide_mouse(); 1362 | button_3d(390, 350, 420, 370, UNCLICKED, "M-", 0); 1363 | show_mouse(); 1364 | ch = '<'; 1365 | return ch; 1366 | } 1367 | if (X >= 350 && X <= 380 && Y >= 350 && Y <= 370) // Condition For M+ 1368 | { 1369 | hide_mouse(); 1370 | button_3d(350, 350, 380, 370, CLICKED, "M+", 0); 1371 | show_mouse(); 1372 | delay(250); 1373 | hide_mouse(); 1374 | button_3d(350, 350, 380, 370, UNCLICKED, "M+", 0); 1375 | show_mouse(); 1376 | ch = '>'; 1377 | return ch; 1378 | } 1379 | 1380 | if (X >= 220 && X <= 270 && Y >= 250 && Y <= 275) // Condition For tan^-1 1381 | { 1382 | hide_mouse(); 1383 | button_3d(220, 250, 270, 275, CLICKED, "tan^-1", 0); 1384 | show_mouse(); 1385 | delay(250); 1386 | hide_mouse(); 1387 | button_3d(220, 250, 270, 275, UNCLICKED, "tan^-1", 0); 1388 | show_mouse(); 1389 | ch = 'k'; 1390 | return ch; 1391 | } 1392 | //************************** 1393 | 1394 | if (X >= 100 && X <= 150 && Y >= 300 && Y <= 325) // Condition For ln 1395 | { 1396 | hide_mouse(); 1397 | button_3d(100, 300, 150, 325, CLICKED, "ln", 0); 1398 | show_mouse(); 1399 | delay(250); 1400 | hide_mouse(); 1401 | button_3d(100, 300, 150, 325, UNCLICKED, "ln", 0); 1402 | show_mouse(); 1403 | ch = 'n'; 1404 | return ch; 1405 | } 1406 | //************************** 1407 | 1408 | if (X >= 160 && X <= 210 && Y >= 300 && Y <= 325) // Condition For log 1409 | { 1410 | hide_mouse(); 1411 | button_3d(160, 300, 210, 325, CLICKED, "log", 0); 1412 | show_mouse(); 1413 | delay(150); 1414 | hide_mouse(); 1415 | button_3d(160, 300, 210, 325, UNCLICKED, "log", 0); 1416 | show_mouse(); 1417 | ch = 'l'; 1418 | return ch; 1419 | } 1420 | //************************** 1421 | 1422 | if (X >= 220 && X <= 270 && Y >= 300 && Y <= 325) // Condition For X^2 1423 | { 1424 | hide_mouse(); 1425 | button_3d(220, 300, 270, 325, CLICKED, "x^2", 0); 1426 | show_mouse(); 1427 | delay(250); 1428 | hide_mouse(); 1429 | button_3d(220, 300, 270, 325, UNCLICKED, "x^2", 0); 1430 | show_mouse(); 1431 | ch = 'p'; 1432 | return ch; 1433 | } 1434 | if (X >= 100 && X <= 150 && Y >= 350 && Y <= 370) // Condition For deg 1435 | { 1436 | hide_mouse(); 1437 | button_3d(100, 350, 150, 370, CLICKED, "deg", 15); 1438 | button_3d(160, 350, 210, 370, UNCLICKED, "rad", 0); 1439 | button_3d(220, 350, 270, 370, UNCLICKED, "gra", 0); 1440 | show_mouse(); 1441 | delay(250); 1442 | hide_mouse(); 1443 | button_3d(100, 350, 150, 370, UNCLICKED, "deg", 15); 1444 | show_mouse(); 1445 | ch = 'd'; 1446 | flagp = flag; 1447 | flag = ch; 1448 | return ch; 1449 | } 1450 | //************************** 1451 | if (X >= 160 && X <= 210 && Y >= 350 && Y <= 370) // Condition For rad 1452 | { 1453 | hide_mouse(); 1454 | button_3d(100, 350, 150, 370, UNCLICKED, "deg", 0); 1455 | button_3d(160, 350, 210, 370, CLICKED, "rad", 15); 1456 | button_3d(220, 350, 270, 370, UNCLICKED, "gra", 0); 1457 | show_mouse(); 1458 | delay(250); 1459 | hide_mouse(); 1460 | button_3d(160, 350, 210, 370, UNCLICKED, "rad", 15); 1461 | show_mouse(); 1462 | ch = 'r'; 1463 | flagp = flag; 1464 | flag = ch; 1465 | 1466 | return ch; 1467 | } 1468 | if (X >= 220 && X <= 270 && Y >= 350 && Y <= 370) // Condition For gra 1469 | { 1470 | hide_mouse(); 1471 | button_3d(100, 350, 150, 370, UNCLICKED, "deg", 0); 1472 | button_3d(160, 350, 210, 370, UNCLICKED, "rad", 0); 1473 | button_3d(220, 350, 270, 370, CLICKED, "gra", 15); 1474 | show_mouse(); 1475 | delay(250); 1476 | hide_mouse(); 1477 | button_3d(220, 350, 270, 370, UNCLICKED, "gra", 15); 1478 | show_mouse(); 1479 | ch = 'g'; 1480 | flagp = flag; 1481 | flag = ch; 1482 | return ch; 1483 | 1484 | } 1485 | if ((X >= 480 && X <= 545 && Y >= 350 && Y <= 370) || (X >= 575 && X <= 595 && Y >= 23 && Y <= 40)) //OFF 1486 | { 1487 | free(mem); 1488 | exit(0); 1489 | } 1490 | if (X >= 108 && X <= 208 && Y >= 140 && Y <= 160) // Condition For dec 1491 | { 1492 | hide_mouse(); 1493 | button_3d(108, 140, 208, 160, CLICKED, "DEC", 15); 1494 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 0); 1495 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 0); 1496 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 0); 1497 | show_mouse(); 1498 | delay(250); 1499 | hide_mouse(); 1500 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 15); 1501 | show_mouse(); 1502 | ch = 'u'; 1503 | bflagp = bflag; 1504 | bflag = ch; 1505 | return ch; 1506 | } 1507 | if (X >= 218 && X <= 318 && Y >= 140 && Y <= 160) // Condition For oct 1508 | { 1509 | hide_mouse(); 1510 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 0); 1511 | button_3d(218, 140, 318, 160, CLICKED, "OCT", 15); 1512 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 0); 1513 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 0); 1514 | show_mouse(); 1515 | delay(250); 1516 | hide_mouse(); 1517 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 15); 1518 | show_mouse(); 1519 | ch = 'v'; 1520 | bflagp = bflag; 1521 | bflag = ch; 1522 | return ch; 1523 | } 1524 | if (X >= 328 && X <= 428 && Y >= 140 && Y <= 160) // Condition For hex 1525 | { 1526 | hide_mouse(); 1527 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 0); 1528 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 0); 1529 | button_3d(328, 140, 428, 160, CLICKED, "HEX", 15); 1530 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 0); 1531 | show_mouse(); 1532 | delay(250); 1533 | hide_mouse(); 1534 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 15); 1535 | show_mouse(); 1536 | ch = 'w'; 1537 | bflagp = bflag; 1538 | bflag = ch; 1539 | return ch; 1540 | } 1541 | if (X >= 438 && X <= 538 && Y >= 140 && Y <= 160) // Condition For dec 1542 | { 1543 | hide_mouse(); 1544 | button_3d(108, 140, 208, 160, UNCLICKED, "DEC", 0); 1545 | button_3d(218, 140, 318, 160, UNCLICKED, "OCT", 0); 1546 | button_3d(328, 140, 428, 160, UNCLICKED, "HEX", 0); 1547 | button_3d(438, 140, 538, 160, CLICKED, "BIN", 15); 1548 | show_mouse(); 1549 | delay(250); 1550 | hide_mouse(); 1551 | button_3d(438, 140, 538, 160, UNCLICKED, "BIN", 15); 1552 | show_mouse(); 1553 | ch = 'x'; 1554 | bflagp = bflag; 1555 | bflag = ch; 1556 | return ch; 1557 | } 1558 | if (X >= 480 && X <= 510 && Y >= 280 && Y <= 300) { 1559 | hide_mouse(); 1560 | button_3d(480, 280, 510, 300, CLICKED, "sqrt", 0); 1561 | show_mouse(); 1562 | delay(250); 1563 | hide_mouse(); 1564 | button_3d(480, 280, 510, 300, UNCLICKED, "sqrt", 0); 1565 | show_mouse(); 1566 | ch = 'q'; 1567 | return ch; 1568 | } 1569 | 1570 | } while (kbhit() == 0); 1571 | ch = getch(); 1572 | return ch; 1573 | } 1574 | 1575 | //*********************************************** 1576 | // * 1577 | // This function performs the Calculations * 1578 | // * 1579 | //*********************************************** 1580 | double add(double x, double y, char ch) { 1581 | switch (ch) { 1582 | case '+': 1583 | y = x + y; 1584 | break; 1585 | case '-': 1586 | y = x - y; 1587 | break; 1588 | case '*': 1589 | y = x * y; 1590 | break; 1591 | case '/': 1592 | y = x / y; 1593 | } 1594 | return y; 1595 | } 1596 | 1597 | double angle_conv(double no) { 1598 | if (flagp == 'd') { 1599 | if (flag == 'r') { 1600 | no = no * PI / 180; 1601 | } 1602 | if (flag == 'g') { 1603 | no = no * 1.1111111; 1604 | } 1605 | } else if (flagp == 'r') { 1606 | if (flag == 'd') { 1607 | no = no * 180 / PI; 1608 | } 1609 | if (flag == 'g') { 1610 | no = no * 180 / PI * 1.1111111; 1611 | } 1612 | } else if (flagp == 'g') { 1613 | if (flag == 'r') { 1614 | no = no / (180 * 1.1111111) * PI; 1615 | } 1616 | if (flag == 'd') { 1617 | no = no / 1.1111111; 1618 | } 1619 | } 1620 | return (no); 1621 | } 1622 | 1623 | void basecng(double y, double pnt1) { 1624 | char str[17]; 1625 | if (pnt1 != 0) { 1626 | gotoxy(row, col); 1627 | printf("The trial version does not support this feature"); 1628 | getch(); 1629 | bflag = 'u'; 1630 | bflagp = '0'; 1631 | main(); 1632 | } 1633 | if (bflagp != 'u') { 1634 | gotoxy(row, col); 1635 | printf("The trial version does not support this feature "); 1636 | getch(); 1637 | bflagp = '0'; 1638 | bflag = 'u'; 1639 | main(); 1640 | } 1641 | switch (bflag) { 1642 | case 'v': 1643 | itoa(y, str, 8); 1644 | gotoxy(row, col); 1645 | printf("\t\t\t\t "); 1646 | gotoxy(row, col); 1647 | printf("%s", str); 1648 | bflagp = '0'; 1649 | break; 1650 | 1651 | case 'w': 1652 | itoa(y, str, 16); 1653 | gotoxy(row, col); 1654 | printf("\t\t\t\t "); 1655 | gotoxy(row, col); 1656 | printf("%s", str); 1657 | bflagp = '0'; 1658 | // getch(); 1659 | break; 1660 | 1661 | case 'x': 1662 | itoa(y, str, 2); 1663 | gotoxy(row, col); 1664 | printf("\t\t\t\t "); 1665 | gotoxy(row, col); 1666 | printf("%s", str); 1667 | // getch(); 1668 | bflagp = '0'; 1669 | break; 1670 | } 1671 | bflag = 'u'; 1672 | } 1673 | 1674 | --------------------------------------------------------------------------------