Sunday, April 15, 2012

Transfer files between two computers

Image this, you are at your friend's house, and he has a hard disk full of data, that you would like to copy to your laptop.
But you only have a 4GB pen drive and copying the files between computers can be a tedious one. What if, you could just
connect the two computers using an ethernet cable and directly copy files through it? I am going to show you just that...

Things we need
1. Two Computers
2. An ethernet cable
3. An internet connection (for installing software)
4. Root access to both machines
Now, lets get started...

Lets name the computers 'A' and 'B'
In computer 'A', Install the package openssh on both systems using your package manager, in SUSE, doing "zypper install openssh" does not work, so do it through the YAST Interface
If you are using BroadBand, free the ethernet port of your computer by unplugging the ethernet cable of your modem. 

Start "gnome-terminal" or any other terminal emulator by pressing "Alt + F2" and typing "gnome-terminal"
Become root, by typing the command "su" and entering the root password, to learn how to activate root in ubuntu, see here

type the command "ifconfig [interface] [IP] up". "Interface" can be 'eth0' or 'eth1', use 'eth1' if 'eth0' does not work
"IP" is the IP Address of your computer, for eg. 192.168.1.1, you can use any address you wish.
Now, let us start the service sshd, type the command "service sshd start", in terminal
In computer 'B', repeat all the steps done in computer 'A' but with a change in the IP Address. The IP Address of the two computers, should be different.

Now, go to the computer from which you want to transfer the files, let us say it is Computer 'B' 
Let us first check, if the two computers are succesfully linked, type the following command followed by enter,
ping [IP of Computer 'A'], ie. if the IP Address of the computer 'A' is "192.168.1.1", the command would be "ping 192.168.1.1"
My output of the command is as follows

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=0.098 ms
64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=0.083 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=0.078 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=0.080 ms
64 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=0.064 ms
64 bytes from 192.168.1.1: icmp_req=6 ttl=64 time=0.075 ms

End the program by pressing "Ctrl + C"
If you got a similar output, then we have succeeded in what we have done so far...

Now, let us transfer a file from 'B' to 'A'
as root, type the command "scp [path_to_file] [user]@[IP]:[target_path]" where "path to file is the exact location of file you wish to transfer. "user" is the name of the user account, who will become the owner of the transfered file. Please note that, if you use "root" account, the file can only be accessed by root and you can't use a normal account to transfer files to location owned by "root"
"IP" is the IP Address of Computer 'A' and "target_path" is the exact location, where you wish the file to be saved. for example,
If computer 'B' have an IP Address of "192.168.1.1" and the user being "root" and the file to be transferred is "/file" and
the target location is "/root/file" the command will be "scp /file root@192.168.1.1:/root/file"

But, if you wish to transfer a whole folder of contents, you can add the switch "-r" to the command. Imagine I am moving a folder named "/folder" in Computer 'B' to a folder named "/root/folder", then the command would be:
"scp /folder root@192.168.1.1:/root/folder"

I am feeling a bit tired with all that typing, I hope this tutorial was not in vain...

Linux: Re-establishing a dropped dialup connection

I use a dialup connection, my modem is a Huawei ETS-1201, a fixed wireless terminal, being a newbie, it was very hard
for me to establish a dialup connection in linux, after lots of googling, I finally figured out, how to connect to web.
Then came another issue, what to do, if a connection gets dropped, then I have to plug the usb cord out and then re-plug it,
to make the modem work. It made me thinking, without re-plugging the modem, why cant I just switch off the usb port?
and turn it back on, that way, things would be much simpler... Today, I finally found a way to do it, to know more, just read on...

I assume you are running gnome and the modem is plugged in, for KDE, use konsole instead of gnome-terminal
Press Alt + F2 and type "gnome-terminal"
Become root by typing "su" and pressing enter for ubuntu users, activate the root account before issuing su command
Type the command "dmesg | grep [device]" where [device] should be the name of your device, it can be the vendor ID or
product ID. For Huawei, the vendor ID is 12d1, for finding the product or vendor ID, follow the instructions here
My output of the command is as follows,
[    3.633262] usb 5-1: New USB device found, idVendor=12d1, idProduct=1010
here, "5-1" is the name of my device, it is in this name a folder is created when I plug in the modem, note the number shown,
in your output

Add the command "echo auto > /sys/bus/usb/devices/[device number]/power/control" to "/etc/rc.d/boot.local" or
"/etc/rc.local" or a similar startup script depending on your distribution, detailed instruction can be found here
You should replace [device number] with the number noted from the "dmesg | grep" command. 
You can use editors such as nano or mousepad to do it, but they have to be run as root to be able to edit this file. For detailed instructions, seehere

In the next line of startup script add "modprobe usbcore autosuspend=1" it will reduce the time taken by the device to enter auto suspend to 1 second
Restart your system, establish a connection then cancel it by pressing Ctrl + C, try to re-dial and it should do the job
For more information, you can refer to the Kernel Documentation on USB Power management here

Linux: Finding the product and vendor ID of USB Device

I have several usb devices lying around my table, I can identify them, as my modem, webcam, mouse and so on...
But, Linux impliments another method to identify all the devices connected to it, lets learn a little bit more about it
Press Alt + F2 and type "gnome-terminal"
type lsusb and press enter, my output of the command is as follows

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 005: ID 0ac8:c33f Z-Star Microelectronics Corp. Webcam
Bus 002 Device 002: ID 046d:c05a Logitech, Inc. Optical Mouse M90
Bus 003 Device 002: ID 0a5c:219c Broadcom Corp. 
Bus 005 Device 003: ID 12d1:1010 Huawei Technologies Co., Ltd. ETS2252+ CDMA Fixed Wireless Terminal

Note the two blocks of numbers after the word ID eg."1d6b:0001", here 1d6b is the vendor ID and 0001 is the product ID
finding the vendor and product ID of devices is useful for finding a message about a particular device using "dmesg | grep" command. 

It is also useful for adding driver modules to the kernel, eg. note the last line of the command output,
"Bus 005 Device 003: ID 12d1:1010 Huawei Technologies Co., Ltd. ETS2252+ CDMA Fixed Wireless Terminal" it is my modem,
how do I add its driver to the kernel?
Being root, you can type "modprobe usbserial vendor=0x12d1 product=0x1010" and press enter. Please note that, you have to replace the vendor and product IDs with that of your own devices and prefix them with "0x"
It can be also used by the "usb_modeswitch" command, the default vendor and product IDs that have to be given in the command,
refers to the same IDs given by the "lsusb" command

A program for Displaying Progress Card


/*
An example of badly written program
This program grabs data from a user and displays it
Nothing much to say about it
Try to understand the code :)
*/

#include
#include
#include
#include
#include
void main()
{
float max, ss, ss1, sci, sci1, eng, eng1, math, math1, bio, bio1, it, it1, com, com1, sel, sel1, hin, hin1; //variables with importance!
float engp, gengval, selp, gselval, scip, gscival, itp, gitval, biop, gbioval, comp, gcomval, mathp, gmathval, ssp, gssval, hinp, ghinval, totp, gtotval;
int data_switch, opt, strm, strm1, tot, selopt, std;
char fname[20], fname1[20], lname[20], lname1[20], roll[2], roll1[2], div, div1[20]; //things which doesnt have anything to do with calculations
menu:
clrscr();
cout<<"What do you want to do?"<
cout<<"1] Enter Data"<
cout<<"2] Enter Comparison Data"<
cout<<"3] See Results"<
cout<<"4] See Comparison"<
cout<<"5] About"<
cout<<"6] Exit"<
cout<<"Enter a choice (1-8): ";
cin>>opt;
if (opt>8 || opt<1)
{
clrscr();
cout<<"You must enter a choice between 1 and 8";
getch();
goto menu;
}
if (opt==1)
{
data:
data_switch=1;
clrscr();
cout<<"Enter First Name: ";
cin>>fname;
clrscr();
cout<<"Enter Last Name: ";
cin>>lname;
std:
clrscr();
cout<<"Enter Standard (1-12): ";
cin>>std;
if (std>12 || std<1)
{
clrscr();
cout<<"You must enter a choice between 1 and 12!";
getch();
goto std;
}
clrscr();
cout<<"Enter Division: ";
cin>>div;
clrscr();
cout<<"Enter Roll: ";
cin>>roll;
clrscr();
if (std==11)
{
goto strm;
}
else if (std==12)
{
goto strm;
}
else
{
goto stdin;
}
strm:
clrscr();
cout<<"Enter Stream: "<
cout<<"1] Medicine"<
cout<<"2] Engineering"<
cout<<"3] Commerce"<
cout<<"Enter a choice (1-3): ";
cin>>strm;
if (strm>3)
{
cout<<"You must enter a choice between 1 and 3\n";
getch();
goto strm;
}
stdin:
clrscr();
cout<<"Max marks that can be scored per subject: ";
cin>>max;
eng:
clrscr();
cout<<"Marks obtained for English: ";
cin>>eng;
if (eng>max)
{
cout<<"You must enter marks within the maximum limit!\n";
getch();
goto eng;
}
selin:
clrscr();
cout<<"Do you have Secondary Language?\n";
cout<<"1] Yes\n";
cout<<"2] No\n";
cout<<"Enter a choice (1-2): ";
cin>>selopt;
if (selopt==1)
{
sel:
clrscr();
cout<<"Marks obtained for secondary language: ";
cin>>sel;
if (sel>max)
{
cout<<"You must enter marks within the maximum limit!\n";
getch();
goto sel;
}
}
else
{
cout<<"You must enter a choice between 1 and 2!";
getch();
goto selin;
}
ss:
clrscr();
if (std<11)
{
cout<<"Marks obtained for Social Science: ";
cin>>ss;
if (ss>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto ss;
}
}
it:
clrscr();
if (std<=10)
{
cout<<"Marks obtained for Computer Science: ";
cin>>it;
if (it>max)
{
cout<<"You must enter marks within the maximum limit!\n";
getch();
goto it;
}
}
if (std>10)
{
if (strm==1)
{
msci:
clrscr();
cout<<"Marks obtained for Science (excluding Biology): ";
cin>>sci;
if (sci>max)
{
cout<<"You must enter marks within the maximum limit!\n";
getch();
goto msci;
}
}
if (strm==2)
{
goto sci;
}
if (strm==3)
{
goto com;
}
}
sci: //pointing geeks to this place :)
clrscr();
cout<<"Marks obtained for Science ";
cin>>sci;
if (sci>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto sci;
}
math:
clrscr();
cout<<"Marks obtained for Maths: ";
cin>>math;
if (math>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto math;
}
hsit:
clrscr();
if (strm==2) //custom input for seperate streams!
{
cout<<"Marks obtained for Computer Science: ";
cin>>it;
if (it>max)
{
cout<<"You must enter marks within the limit!\n";
         getch();
goto hsit;
}
}
med:
clrscr();
if (strm==1)
{
cout<<"Marks obtained for Biology: ";
cin>>bio;
if (bio>max)
{
cout<<"You must enter marks within the limit!\n";
goto med;
}
}
com: //Just a label, to direct commerce students away from the hassle of science!
clrscr();
if (strm==3)
{
cout<<"Marks obtained for Commerce: ";
cin>>com;
if (com>max)
{
cout<<"You must enter marks  within the limit!\n";
getch();
goto com;
}
cit:
clrscr();
cout<<"Marks obtained for Computer Science: ";
cin>>it;
if (it>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto cit;
}
}
hin:
if (std<11)
{
clrscr();
cout<<"Marks obtained for Hindi: ";
cin>>hin;
if (hin>max)
{
cout<<"YOu must enter marks within the limit!\n";
getch();
goto hin;
}
}
clrscr();
cout<<"Data has succesfully been entered!\n";
cout<<"Please press Return to continue...";
getch();
goto menu;
}
if (opt==2)
{
clrscr();
cout<<"Enter First Name: ";
cin>>fname1;
clrscr();
cout<<"Enter Last Name: ";
cin>>lname1;
clrscr();
cout<<"Enter Division: ";
cin>>div1;
clrscr();
cout<<"Enter Roll: ";
cin>>roll1;
clrscr();
if (std==11)
{
goto strm1;
}
else if (std==12)
{
goto strm1;
}
else
{
goto stdin1;
}
strm1:
cout<<"Enter Stream: "<
cout<<"1] Medicine"<
cout<<"2] Engineering"<
cout<<"3] Commerce"<
cout<<"Enter a choice (1-3): ";
cin>>strm1;
if (strm1>3)
{
clrscr();
cout<<"You must enter a choice between 1 and 3\n";
getch();
goto strm1;
}
stdin1:
clrscr();
cout<<"Marks obtained for English: ";
cin>>eng1;
if (eng1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto stdin1;
}
sel1:
if (selopt==1)
{
clrscr();
cout<<"Marks obtained for secondary language: ";
cin>>sel1;
if (sel1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto sel1;
}
}
ss1:
clrscr();
if (std<11)
{
cout<<"Marks obtained for Social Science: ";
cin>>ss1;
if (ss1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto ss1;
}
}
it1:
clrscr();
if (std<=10)
{
cout<<"Marks obtained for Computer Science: ";
cin>>it1;
if (it1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto it1;
}
}
if (std>10)
{
if (strm1==1)
{
msci1:
clrscr();
cout<<"Marks obtained for Science (excluding Biology): ";
cin>>sci1;
if (sci1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto msci1;
}
}
if (strm1==2)
{
goto sci1;
}
if (strm1==3)
{
goto com1;
}
}
sci1: //pointing geeks to this place :)
clrscr();
cout<<"Marks obtained for Science ";
cin>>sci1;
if (sci1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto sci1;
}
math1:
clrscr();
cout<<"Marks obtained for Maths: ";
cin>>math1;
if (math1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto math1;
}
hsit1:
clrscr();
if (strm1==2) //custom input for seperate streams!
{
cout<<"Marks obtained for Computer Science: ";
cin>>it1;
if (it1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto hsit1;
}
}
med1:
clrscr();
if (strm1==2)
{
cout<<"Marks obtained for Biology: ";
cin>>bio1;
if (bio1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto med1;
}
}
com1: //Just a label, to direct commerce students away from the hassle of science!
clrscr();
if (strm1==3)
{
cout<<"Marks obtained for Commerce: ";
cin>>com1;
if (com1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto com1;
}
cit1:
clrscr();
cout<<"Marks obtained for Computer Science: ";
cin>>it1;
if (it1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto cit1;
}
}
hin1:
if (std<11)
{
clrscr();
cout<<"Marks obtained for Hindi: ";
cin>>hin1;
if (hin1>max)
{
cout<<"You must enter marks within the limit!\n";
getch();
goto hin1;
}
}
clrscr();
cout<<"Comparison data has succesfully been entered!\n";
cout<<"Please press Return to continue...";
getch();
goto menu;
}
if (opt==3)
{
clrscr();
cout<<"--Basic Info--------------------------------------------------------------------\n";
cout<<"First Name of Student - "<
cout<<"Last Name of Student  - "<
cout<<"Standard              - "<
cout<<"Division              - "<
cout<<"Roll No.              - "<
if (std>10)
{
cout<<"Stream                - ";
if (strm==1)
{
cout<<"Medicine\n";
}
else if (strm==2)
{
cout<<"Engineering\n";
}
else if (strm==3)
{
cout<<"Commerce\n";
}
}
cout<
cout<<"--Marks-------------------------------------------------------------------------\n";
cout<<"English               - "<
if (selopt==1)
{
cout<<"Secondary Language    - "<
}
if (std<11 || strm==1 || strm==2)
{
cout<<"Science               - "<
 }
if (std<11)
{
goto coutit;
}
if (strm==2)
{
goto coutit;
}
if (strm==3)
{
goto coutit;
}
coutit:
cout<<"Computer Science      - "<
if (strm==1)
{
cout<<"Biology   - "<
}
if (strm==3)
{
cout<<"Commerce      - "<
}
else
{
cout<<"Maths                 - "<
}
if (std<11)
{
cout<<"Social Science        - "<
}
if (std<11)
{
cout<<"Hindi                 - "<
}
if (std<11)
{
tot=ss+sci+eng+sel+it+math+hin;
totp=(tot/(max*6))*100;
cout<<"Total Marks           - "<
}
if (strm==1)
{
tot=eng+math+bio+sci+sel;
totp=(tot/(max*5))*100;
cout<<"Total Marks           - "<
}
if (strm==2)
{
tot=eng+math+sci+it+sel;
totp=(tot/(max*5))*100;
cout<<"Total Marks           - "<
}
if (strm==3)
{
 tot=eng+sci+com+it+sel;
cout<<"Total Marks           - "<
}
cout<
cout<<"--Graph-------------------------------------------------------------------------\n";
cout<<"English              - [";
engp=(eng/max)*100;
gengval=engp/5;
for (int graphval=0;graphval
{
cout<<"=";
}
for (int lineval=0;lineval<20-graphval;++lineval)
{
cout<<" ";
}
cout<<"]"<
if (selopt==1)
{
cout<<"Secondary Language   - [";
selp=(sel/max)*100;
gselval=selp/5;
for (int graphval1=0;graphval1
{
cout<<"=";
}
for (int lineval1=0;lineval1<20-graphval1;++lineval1)
{
cout<<" ";
}
cout<<"]"<
}
if (std<11 || strm!=3)
{
cout<<"Science              - [";
scip=(sci/max)*100;
gscival=scip/5;
for (int graphval2=0;graphval2
{
cout<<"=";
}
for (int lineval2=0;lineval2<20-graphval2;++lineval2)
{
cout<<" ";
}
cout<<"]"<
}
if (strm==2 || strm==3 || std<11)
{
cout<<"Computer Science     - [";
itp=(it/max)*100;
gitval=itp/5;
for (int graphval3=0;graphval3
{
cout<<"=";
}
for (int lineval3=0;lineval3<20-graphval3;++lineval3)
{
cout<<" ";
}
cout<<"]"<
}
if (strm==1)
{
cout<<"Biology   - [";
biop=(bio/max)*100;
gbioval=biop/5;
for (int graphval4=0;graphval4
{
cout<<"=";
}
for (int lineval4=0;lineval4<20-graphval4;++lineval4)
{
cout<<" ";
}
cout<<"]"<
}
if (strm==3)
{
cout<<"Commerce             - [";
comp=(com/max)*100;
gcomval=comp/5;
for (int graphval5=0;graphval5
{
cout<<"=";
}
for (int lineval5=0;lineval5<20-graphval5;++lineval5)
{
cout<<" ";
}
cout<<"]"<
}
if (strm==1 || strm==2 || std<11)
{
cout<<"Mathematics          - [";
mathp=(math/max)*100;
gmathval=mathp/5;
for (int graphval6=0;graphval6
{
cout<<"=";
}
for (int lineval6=0;lineval6<20-graphval6;++lineval6)
{
cout<<" ";
}
cout<<"]"<
}
if (std<11)
{
cout<<"Social Science       - [";
ssp=(ss/max)*100;
gssval=ssp/5;
for (int graphval7=0;graphval7
{
cout<<"=";
}
for (int lineval7=0;lineval7<20-graphval7;++lineval7)
{
cout<<" ";
}
cout<<"]"<
}
if (std<11)
{
cout<<"Hindi                - [";
hinp=(hin/max)*100;
ghinval=hinp/5;
for (int graphval9=0;graphval9
{
cout<<"=";
}
for (int lineval9=0;lineval9<20-graphval9;++lineval9)
{
cout<<" ";
}
cout<<"]"<
}
cout<<"Total Marks          - [";
gtotval=totp/5;
for (int graphval8=0;graphval8
{
cout<<"=";
}
for (int lineval8=0;lineval8<20-graphval8;++lineval8)
{
cout<<" ";
}
cout<<"]"<
}
}

A Program for finding roots of quadratic polynomials


/*
The Rooter
One day, my eyes stuck on Program No.13 of the program sheet teacher had given me
I started developing it and saw that, it would be fun to make it more sophisticated
I incorporated some of the things in this program that I wanted to do for a long time
First of all, The credit screen has ASCII art which I love very much and I am looking for a way to include ANSI too
The menu and the input screen makes use of "SetConsoleCursorPosition" in windows.h to make it appear centered
The credit screen music is accessed and played with the help of mmsystem.h
Overall this program offers pretty much nothing that can be considered as significant
I think I have wasted a lot of time which could be used for doing something useful...
Compile this Borland C Compiler
-Aswin Babu K (aswinbabuk@gmail.com)
*/

#include //It is my usual behaviour to add iostream.h to whatever nonsense i write :)
#include //for textcolor() and textbackground()
#include //Control flow
#include //For setting the cursor position
#include //Credit screen music
#include //Timer (sleep function)
#include //For calculating the roots
#include //For mcisendstring

char opt;
int flag;
int a, b, c;
float root, r1, r2;

void menu();
void credit();
void quad();
void linear();
void cursor(short, short);

void cursor (short x, short y)
{
COORD coord = {x, y};
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), coord);
}

void main()
{
credit();
menu();
}

void menu()
{
start:
clrscr();
cursor (15, 8); //Top Border
textbackground (LIGHTBLUE);
cprintf ("                                                 ");
cursor (15, 15); //Bottom border
cprintf ("                                                 ");
for (int i=9; i<15; ++i)
{
   cursor (15, i);
   cprintf (" ");
   }
for (int i=9; i<15; ++i)
{
   cursor (63, i);
   cprintf (" ");
   }
textbackground (BLACK);
textcolor (YELLOW);
cursor (16, 9);
cprintf ("What do you want to do?"); //The real menu items start here
cursor (16, 10);
cprintf ("1] Solve  a linear equation");
cursor (16, 11);
cprintf ("2] Solve a quadratic equation");
cursor (16, 12);
cprintf ("3] Credits");
cursor (16, 13);
cprintf ("4] Exit");
cursor (16, 14);
cprintf ("Enter a choice (1-4): "); //The real menu items end here
cin>>opt;
if (opt=='1')
{
   linear();
   }
if (opt=='2')
{
   quad();
   }
if (opt=='3')
{
   flag=1;
   credit();
   }
if (opt=='4')
{
   exit(0);
   }
else
{
   clrscr();
   cursor (32, 12);
   cprintf ("Invalid Option!");
   getch();
   goto start;
   }
}

void credit()
{
clrscr();
textcolor (BLACK + BLINK);
cprintf ("Version: 0.5.8 [Build: SA2801121815]                                            ");
cursor (0, 4);
textcolor (LIGHTGREEN);
cprintf ("          ,`""',");
cout<
cprintf ("         ;' ` ;");
cout<
cprintf ("         ;`,',;");
cout<
cprintf ("         ;' ` ;");
textcolor (LIGHTRED);
cprintf ("                      @@@@@@@ @@@  @@@ @@@@@@@@");
cout<
textcolor (LIGHTGREEN);
cprintf ("    ,,,  ;`,',;");
textcolor (LIGHTRED);
cprintf ("                        @@!   @@!  @@@ @@!     ");
cout<
textcolor (LIGHTGREEN);
cprintf ("   ;,` ; ;' ` ;   ,',");
textcolor (LIGHTRED);
cprintf ("                  @!!   @!@!@!@! @!!!:!  ");
cout<
textcolor (LIGHTGREEN);
cprintf ("   ;`,'; ;`,',;  ;,' ;");
textcolor (LIGHTRED);
cprintf ("                 !!:   !!:  !!! !!:     ");
cout<
textcolor (LIGHTGREEN);
cprintf ("   ;',`; ;` ' ; ;`'`';");
textcolor (LIGHTRED);
cprintf ("                  :     :   : : : :: :::");
cout<
textcolor (LIGHTGREEN);
cprintf ("   ;` '',''` `,',`',;");
cout<
textcolor (LIGHTGREEN);
cprintf ("    `''`'; ', ;`'`'");
textcolor (LIGHTRED);
cprintf ("      @@@@@@@   @@@@@@   @@@@@@  @@@@@@@ @@@@@@@@ @@@@@@@");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ;' `';");
textcolor (LIGHTRED);
cprintf ("          @@!  @@@ @@!  @@@ @@!  @@@   @@!   @@!      @@!  @@@");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ;` ' ;");
textcolor (LIGHTRED);
cprintf ("          @!@!!@!  @!@  !@! @!@  !@!   @!!   @!!!:!   @!@!!@!");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ;' `';");
textcolor (LIGHTRED);
cprintf ("          !!: :!!  !!:  !!! !!:  !!!   !!:   !!:      !!: :!!");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ;` ' ;");
textcolor (LIGHTRED);
cprintf ("           :   : :  : :. :   : :. :     :    : :: :::  :   : :");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ; ',';");
cout<
textcolor (LIGHTGREEN);
cprintf ("         ;,' ';");
cout<
textcolor (LIGHTGREEN);
cprintf ("         \|/\|/;\|/");
if (flag==1)
{
mciSendString ("play c:\\Windows\\Media\\Flourish.MID",NULL,0,NULL);
   }
getch();
if (flag==1)
{
   mciSendString ("Stop c:\\Windows\\Media\\Flourish.MID",NULL,0,NULL);
   }
menu();
}

void linear()
{
clrscr();
textbackground (BLACK);
cursor (14, 12);
textcolor (YELLOW);
cprintf ("This functionality has not yet been implimented :(");
getch();
menu();
}

void quad()
{
clrscr();
cursor (15, 9); //Top Border
textbackground (LIGHTBLUE);
cprintf ("                                                 ");
for (int i=9; i<14; ++i)
{
   cursor (15, i);
   cprintf (" ");
   }
for (int i=9; i<14; ++i)
{
   cursor (63, i);
   cprintf (" ");
   }
cursor (15, 14); //Bottom border
textbackground (LIGHTBLUE);
cprintf ("                                                 ");
textbackground (BLACK);
cursor (30, 10);
cprintf ("Ax^2 + Bx + C = 0");
cursor (16, 11);
cprintf ("A:");
cursor (16, 12);
cprintf ("B:");
cursor (16, 13);
cprintf ("C:");
cursor (19, 11);
cin>>a; //input a
cursor (30, 10);
cprintf ("%d", a); //display a
cursor (19, 11);
cprintf ("%d", a);
cursor (19, 12);
cin>>b; //input b
cursor (37, 10);
cprintf ("%d", b); //display b
cursor (19, 12);
cprintf ("%d", b);
cursor (19, 13);
cin>>c; //input c
cursor (42, 10);
cprintf ("%d", c); //display c
cursor (19, 13);
cprintf ("%d", c);
root=sqrt(((b*b)-4)*a*c)/(2*a);
clrscr();
r1=(-b/2*a)+root;
r2=(-b/2*a)-root;
cursor (23, 12);
cprintf ("Roots are: %f", r1);
cprintf (" and %f", r2);
getch();
menu();
}